diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index dfbe28fe5209..48ecf316b708 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -593,6 +593,8 @@ const ONYXKEYS = { NETSUITE_CUSTOM_FORM_ID_FORM_DRAFT: 'netsuiteCustomFormIDFormDraft', SAGE_INTACCT_DIMENSION_TYPE_FORM: 'sageIntacctDimensionTypeForm', SAGE_INTACCT_DIMENSION_TYPE_FORM_DRAFT: 'sageIntacctDimensionTypeFormDraft', + SEARCH_ADVANCED_FILTERS_FORM: 'searchAdvancedFiltersForm', + SEARCH_ADVANCED_FILTERS_FORM_DRAFT: 'searchAdvancedFiltersFormDraft', }, } as const; @@ -665,6 +667,7 @@ type OnyxFormValuesMapping = { [ONYXKEYS.FORMS.NETSUITE_TOKEN_INPUT_FORM]: FormTypes.NetSuiteTokenInputForm; [ONYXKEYS.FORMS.NETSUITE_CUSTOM_FORM_ID_FORM]: FormTypes.NetSuiteCustomFormIDForm; [ONYXKEYS.FORMS.SAGE_INTACCT_DIMENSION_TYPE_FORM]: FormTypes.SageIntacctDimensionForm; + [ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM]: FormTypes.SearchAdvancedFiltersForm; }; type OnyxFormDraftValuesMapping = { diff --git a/src/libs/actions/Search.ts b/src/libs/actions/Search.ts index 969812b02b02..245192ff6e0a 100644 --- a/src/libs/actions/Search.ts +++ b/src/libs/actions/Search.ts @@ -1,5 +1,6 @@ import Onyx from 'react-native-onyx'; import type {OnyxUpdate} from 'react-native-onyx'; +import type {FormOnyxValues} from '@components/Form/types'; import * as API from '@libs/API'; import type {SearchParams} from '@libs/API/parameters'; import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; @@ -108,4 +109,12 @@ function exportSearchItemsToCSV(query: string, reportIDList: Array) { + Onyx.merge(ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM, values); +} + +export {search, createTransactionThread, deleteMoneyRequestOnSearch, holdMoneyRequestOnSearch, unholdMoneyRequestOnSearch, exportSearchItemsToCSV, updateAdvancedFilters}; diff --git a/src/pages/Search/SearchFiltersDatePage.tsx b/src/pages/Search/SearchFiltersDatePage.tsx index 6565da078367..9ac9973c8ca2 100644 --- a/src/pages/Search/SearchFiltersDatePage.tsx +++ b/src/pages/Search/SearchFiltersDatePage.tsx @@ -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]; + + const updateDateFilter = (values: FormOnyxValues) => { + updateAdvancedFilters(values); + Navigation.goBack(ROUTES.SEARCH_ADVANCED_FILTERS); + }; + return ( - - {/* temporary placeholder, will be implemented in https://github.com/Expensify/App/issues/45026 */} - Advanced filters Date form - + + + + ); diff --git a/src/types/form/SearchAdvancedFiltersForm.ts b/src/types/form/SearchAdvancedFiltersForm.ts new file mode 100644 index 000000000000..46808954f661 --- /dev/null +++ b/src/types/form/SearchAdvancedFiltersForm.ts @@ -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; + +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; diff --git a/src/types/form/index.ts b/src/types/form/index.ts index 3c6946dd97e8..a6ef63329006 100644 --- a/src/types/form/index.ts +++ b/src/types/form/index.ts @@ -62,5 +62,6 @@ export type {SageIntactCredentialsForm} from './SageIntactCredentialsForm'; export type {NetSuiteCustomFieldForm} from './NetSuiteCustomFieldForm'; export type {NetSuiteTokenInputForm} from './NetSuiteTokenInputForm'; export type {NetSuiteCustomFormIDForm} from './NetSuiteCustomFormIDForm'; +export type {SearchAdvancedFiltersForm} from './SearchAdvancedFiltersForm'; export type {EditExpensifyCardLimitForm} from './EditExpensifyCardLimitForm'; export type {default as Form} from './Form';