-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Advanced date filter view #45756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Advanced date filter view #45756
Changes from all commits
01c305e
8d0553f
1181d33
ff8a371
386883e
21d9313
6cdaf02
affa303
f15f380
8a90596
8d2ee8c
24ef438
db715b2
ab8511e
1f80ee7
a25eb54
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,34 @@ | ||
| import React from 'react'; | ||
| import {View} from 'react-native'; | ||
| import {useOnyx} from 'react-native-onyx'; | ||
| import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; | ||
| import DatePicker from '@components/DatePicker'; | ||
| import FormProvider from '@components/Form/FormProvider'; | ||
| import InputWrapper from '@components/Form/InputWrapper'; | ||
| import type {FormOnyxValues} from '@components/Form/types'; | ||
| import HeaderWithBackButton from '@components/HeaderWithBackButton'; | ||
| import ScreenWrapper from '@components/ScreenWrapper'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import Text from '@src/components/Text'; | ||
| import {updateAdvancedFilters} from '@libs/actions/Search'; | ||
| import Navigation from '@libs/Navigation/Navigation'; | ||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import ROUTES from '@src/ROUTES'; | ||
| import INPUT_IDS from '@src/types/form/SearchAdvancedFiltersForm'; | ||
|
|
||
| function SearchFiltersDatePage() { | ||
| const styles = useThemeStyles(); | ||
| const {translate} = useLocalize(); | ||
|
|
||
| const [searchAdvancedFiltersForm] = useOnyx(ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM); | ||
| const dateAfter = searchAdvancedFiltersForm?.[INPUT_IDS.DATE_AFTER]; | ||
| const dateBefore = searchAdvancedFiltersForm?.[INPUT_IDS.DATE_BEFORE]; | ||
|
Comment on lines
+24
to
+25
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Guccio163 - Another NAB comment 😄: We can define
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Kicu maybe we can address this in your PR? |
||
|
|
||
| const updateDateFilter = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM>) => { | ||
| updateAdvancedFilters(values); | ||
| Navigation.goBack(ROUTES.SEARCH_ADVANCED_FILTERS); | ||
| }; | ||
|
|
||
| return ( | ||
| <ScreenWrapper | ||
| testID={SearchFiltersDatePage.displayName} | ||
|
|
@@ -19,10 +37,30 @@ function SearchFiltersDatePage() { | |
| > | ||
| <FullPageNotFoundView shouldShow={false}> | ||
| <HeaderWithBackButton title={translate('common.date')} /> | ||
| <View style={[styles.flex1, styles.ph3]}> | ||
| {/* temporary placeholder, will be implemented in https://github.com/Expensify/App/issues/45026 */} | ||
| <Text>Advanced filters Date form</Text> | ||
| </View> | ||
| <FormProvider | ||
| style={[styles.flex1, styles.ph5]} | ||
| formID={ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM} | ||
| onSubmit={updateDateFilter} | ||
| submitButtonText={translate('common.save')} | ||
| enabledWhenOffline | ||
| > | ||
| <InputWrapper | ||
| InputComponent={DatePicker} | ||
| inputID={INPUT_IDS.DATE_AFTER} | ||
| label={translate('search.filters.date.after')} | ||
| defaultValue={dateAfter} | ||
| maxDate={CONST.CALENDAR_PICKER.MAX_DATE} | ||
| minDate={CONST.CALENDAR_PICKER.MIN_DATE} | ||
| /> | ||
| <InputWrapper | ||
| InputComponent={DatePicker} | ||
| inputID={INPUT_IDS.DATE_BEFORE} | ||
| label={translate('search.filters.date.before')} | ||
| defaultValue={dateBefore} | ||
| maxDate={CONST.CALENDAR_PICKER.MAX_DATE} | ||
| minDate={CONST.CALENDAR_PICKER.MIN_DATE} | ||
| /> | ||
| </FormProvider> | ||
| </FullPageNotFoundView> | ||
| </ScreenWrapper> | ||
| ); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import type {ValueOf} from 'type-fest'; | ||
| import type Form from './Form'; | ||
|
|
||
| const INPUT_IDS = { | ||
| TYPE: 'type', | ||
| DATE_AFTER: 'dateAfter', | ||
| DATE_BEFORE: 'dateBefore', | ||
| } as const; | ||
|
|
||
| type InputID = ValueOf<typeof INPUT_IDS>; | ||
|
|
||
| type SearchAdvancedFiltersForm = Form< | ||
| InputID, | ||
| { | ||
| [INPUT_IDS.TYPE]: string; | ||
| [INPUT_IDS.DATE_AFTER]: string; | ||
| [INPUT_IDS.DATE_BEFORE]: string; | ||
| } | ||
| >; | ||
|
|
||
| export type {SearchAdvancedFiltersForm}; | ||
| export default INPUT_IDS; |
Uh oh!
There was an error while loading. Please reload this page.