From 449f22ab1025ac1d29dafa451126c89e10765599 Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Tue, 13 Aug 2024 17:53:03 +0200 Subject: [PATCH 01/13] add AmountWithoutCurrencyForm component --- src/CONST.ts | 1 + src/components/AmountWithoutCurrencyForm.tsx | 55 ++++++++++++++++++++ src/libs/SearchUtils.ts | 5 ++ 3 files changed, 61 insertions(+) create mode 100644 src/components/AmountWithoutCurrencyForm.tsx diff --git a/src/CONST.ts b/src/CONST.ts index 84b393a1f5ae..dfae746ab178 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1187,6 +1187,7 @@ const CONST = { VISIBLE_PASSWORD: 'visible-password', ASCII_CAPABLE: 'ascii-capable', NUMBER_PAD: 'number-pad', + DECIMAL_PAD: 'decimal-pad', }, INPUT_MODE: { diff --git a/src/components/AmountWithoutCurrencyForm.tsx b/src/components/AmountWithoutCurrencyForm.tsx new file mode 100644 index 000000000000..0c24bf47e5da --- /dev/null +++ b/src/components/AmountWithoutCurrencyForm.tsx @@ -0,0 +1,55 @@ +import React, {useCallback, useMemo} from 'react'; +import useLocalize from '@hooks/useLocalize'; +import {replaceAllDigits, stripSpacesFromAmount, validateAmount} from '@libs/MoneyRequestUtils'; +import {replaceCommaWithDot} from '@libs/SearchUtils'; +import CONST from '@src/CONST'; +import TextInput from './TextInput'; +import type {BaseTextInputProps} from './TextInput/BaseTextInput/types'; + +type AmountFormProps = { + /** Amount supplied by the FormProvider */ + value?: string; + + /** Callback to update the amount in the FormProvider */ + onInputChange?: (value: string) => void; +} & Partial; + +function AmountWithoutCurrencyForm({value: amount, onInputChange, ...rest}: AmountFormProps) { + const {toLocaleDigit} = useLocalize(); + + const currentAmount = useMemo(() => (typeof amount === 'string' ? amount : ''), [amount]); + + /** + * Sets the selection and the amount accordingly to the value passed to the input + * @param newAmount - Changed amount from user input + */ + const setNewAmount = useCallback( + (newAmount: string) => { + // Remove spaces from the newAmount value because Safari on iOS adds spaces when pasting a copied value + // More info: https://github.com/Expensify/App/issues/16974 + const newAmountWithoutSpaces = stripSpacesFromAmount(newAmount); + const replacedCommasAmount = replaceCommaWithDot(newAmountWithoutSpaces); + if (!validateAmount(replacedCommasAmount, 3)) { + return; + } + onInputChange?.(replacedCommasAmount); + }, + [onInputChange], + ); + + const formattedAmount = replaceAllDigits(currentAmount, toLocaleDigit); + + return ( + + ); +} + +AmountWithoutCurrencyForm.displayName = 'AmountWithoutCurrencyForm'; + +export default AmountWithoutCurrencyForm; diff --git a/src/libs/SearchUtils.ts b/src/libs/SearchUtils.ts index 9ed9a97821bb..f7512bf826ee 100644 --- a/src/libs/SearchUtils.ts +++ b/src/libs/SearchUtils.ts @@ -74,6 +74,10 @@ function getTransactionItemCommonFormattedProperties( }; } +function replaceCommaWithDot(amount: string): string { + return amount.replace(/,/g, '.'); +} + function isSearchDataType(type: string): type is SearchDataTypes { const searchDataTypes: string[] = Object.values(CONST.SEARCH.DATA_TYPES); return searchDataTypes.includes(type); @@ -574,4 +578,5 @@ export { normalizeQuery, shouldShowYear, getExpenseTypeTranslationKey, + replaceCommaWithDot, }; From afa7e1c2ccb15d354653775f20d4f88fc84551e1 Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Tue, 13 Aug 2024 17:53:48 +0200 Subject: [PATCH 02/13] add amount filter page --- src/ROUTES.ts | 1 + src/SCREENS.ts | 1 + src/languages/en.ts | 5 ++ src/languages/es.ts | 5 ++ .../ModalStackNavigators/index.tsx | 1 + .../CENTRAL_PANE_TO_RHP_MAPPING.ts | 1 + src/libs/Navigation/linkingConfig/config.ts | 1 + src/pages/Search/AdvancedSearchFilters.tsx | 18 ++++ src/pages/Search/SearchFiltersAmountPage.tsx | 84 +++++++++++++++++++ src/types/form/SearchAdvancedFiltersForm.ts | 4 + 10 files changed, 121 insertions(+) create mode 100644 src/pages/Search/SearchFiltersAmountPage.tsx diff --git a/src/ROUTES.ts b/src/ROUTES.ts index f6bdaecdf339..5632347d0abc 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -44,6 +44,7 @@ const ROUTES = { SEARCH_ADVANCED_FILTERS_MERCHANT: 'search/filters/merchant', SEARCH_ADVANCED_FILTERS_DESCRIPTION: 'search/filters/description', SEARCH_ADVANCED_FILTERS_REPORT_ID: 'search/filters/reportID', + SEARCH_ADVANCED_FILTERS_AMOUNT: 'search/filters/amount', SEARCH_ADVANCED_FILTERS_CATEGORY: 'search/filters/category', SEARCH_ADVANCED_FILTERS_KEYWORD: 'search/filters/keyword', SEARCH_ADVANCED_FILTERS_CARD: 'search/filters/card', diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 0da8b088f5ec..1de7ad0f5a5b 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -37,6 +37,7 @@ const SCREENS = { ADVANCED_FILTERS_DESCRIPTION_RHP: 'Search_Advanced_Filters_Description_RHP', ADVANCED_FILTERS_MERCHANT_RHP: 'Search_Advanced_Filters_Merchant_RHP', ADVANCED_FILTERS_REPORT_ID_RHP: 'Search_Advanced_Filters_ReportID_RHP', + ADVANCED_FILTERS_AMOUNT_RHP: 'Search_Advanced_Filters_Amount_RHP', ADVANCED_FILTERS_CATEGORY_RHP: 'Search_Advanced_Filters_Category_RHP', ADVANCED_FILTERS_KEYWORD_RHP: 'Search_Advanced_Filters_Keyword_RHP', ADVANCED_FILTERS_CARD_RHP: 'Search_Advanced_Filters_Card_RHP', diff --git a/src/languages/en.ts b/src/languages/en.ts index 2332e7d76cb6..75e6d24cfd6a 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -3676,6 +3676,11 @@ export default { keyword: 'Keyword', hasKeywords: 'Has keywords', currency: 'Currency', + amount: { + lessThan: (amount?: string) => `Less than ${amount ?? ''}`, + greaterThan: (amount?: string) => `Greater than ${amount ?? ''}`, + between: (greaterThan: string, lessThan: string) => `Between ${greaterThan} and ${lessThan}`, + }, }, expenseType: 'Expense type', }, diff --git a/src/languages/es.ts b/src/languages/es.ts index 271ff43a95a9..2d27a1fa2771 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -3730,6 +3730,11 @@ export default { keyword: 'Palabra clave', hasKeywords: 'Tiene palabras clave', currency: 'Divisa', + amount: { + lessThan: (amount?: string) => `Menos de ${amount ?? ''}`, + greaterThan: (amount?: string) => `Más que ${amount ?? ''}`, + between: (greaterThan: string, lessThan: string) => `Entre ${greaterThan} y ${lessThan}`, + }, }, expenseType: 'Tipo de gasto', }, diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 2cdc6bff4e08..6c19eb015308 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -517,6 +517,7 @@ const SearchAdvancedFiltersModalStackNavigator = createModalStackNavigator require('../../../../pages/Search/SearchFiltersDescriptionPage').default, [SCREENS.SEARCH.ADVANCED_FILTERS_MERCHANT_RHP]: () => require('../../../../pages/Search/SearchFiltersMerchantPage').default, [SCREENS.SEARCH.ADVANCED_FILTERS_REPORT_ID_RHP]: () => require('../../../../pages/Search/SearchFiltersReportIDPage').default, + [SCREENS.SEARCH.ADVANCED_FILTERS_AMOUNT_RHP]: () => require('../../../../pages/Search/SearchFiltersAmountPage').default, [SCREENS.SEARCH.ADVANCED_FILTERS_CATEGORY_RHP]: () => require('../../../../pages/Search/SearchFiltersCategoryPage').default, [SCREENS.SEARCH.ADVANCED_FILTERS_KEYWORD_RHP]: () => require('../../../../pages/Search/SearchFiltersKeywordPage').default, [SCREENS.SEARCH.ADVANCED_FILTERS_CARD_RHP]: () => require('../../../../pages/Search/SearchFiltersCardPage').default, diff --git a/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts index b47df57764a5..9224d05679d0 100755 --- a/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts @@ -47,6 +47,7 @@ const CENTRAL_PANE_TO_RHP_MAPPING: Partial> = SCREENS.SEARCH.ADVANCED_FILTERS_DESCRIPTION_RHP, SCREENS.SEARCH.ADVANCED_FILTERS_MERCHANT_RHP, SCREENS.SEARCH.ADVANCED_FILTERS_REPORT_ID_RHP, + SCREENS.SEARCH.ADVANCED_FILTERS_AMOUNT_RHP, SCREENS.SEARCH.ADVANCED_FILTERS_CATEGORY_RHP, SCREENS.SEARCH.ADVANCED_FILTERS_KEYWORD_RHP, SCREENS.SEARCH.ADVANCED_FILTERS_TAX_RATE_RHP, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 204a4b559b03..b29cb825e566 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -1020,6 +1020,7 @@ const config: LinkingOptions['config'] = { [SCREENS.SEARCH.ADVANCED_FILTERS_MERCHANT_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS_MERCHANT, [SCREENS.SEARCH.ADVANCED_FILTERS_DESCRIPTION_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS_DESCRIPTION, [SCREENS.SEARCH.ADVANCED_FILTERS_REPORT_ID_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS_REPORT_ID, + [SCREENS.SEARCH.ADVANCED_FILTERS_AMOUNT_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS_AMOUNT, [SCREENS.SEARCH.ADVANCED_FILTERS_CATEGORY_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS_CATEGORY, [SCREENS.SEARCH.ADVANCED_FILTERS_KEYWORD_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS_KEYWORD, [SCREENS.SEARCH.ADVANCED_FILTERS_CARD_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS_CARD, diff --git a/src/pages/Search/AdvancedSearchFilters.tsx b/src/pages/Search/AdvancedSearchFilters.tsx index 163c5b628bd5..2a04bfdf396a 100644 --- a/src/pages/Search/AdvancedSearchFilters.tsx +++ b/src/pages/Search/AdvancedSearchFilters.tsx @@ -39,6 +39,19 @@ function getFilterDisplayTitle(filters: Partial, fiel return dateValue; } + if (fieldName === CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT) { + const {lessThan, greaterThan} = filters; + if (lessThan && greaterThan) { + return translate('search.filters.amount.between', lessThan, greaterThan); + } + if (lessThan) { + return translate('search.filters.amount.lessThan', lessThan); + } + if (greaterThan) { + return translate('search.filters.amount.greaterThan', greaterThan); + } + } + if ( (fieldName === CONST.SEARCH.SYNTAX_FILTER_KEYS.CATEGORY || fieldName === CONST.SEARCH.SYNTAX_FILTER_KEYS.CURRENCY || fieldName === CONST.SEARCH.SYNTAX_FILTER_KEYS.TAG) && filters[fieldName] @@ -132,6 +145,11 @@ function AdvancedSearchFilters() { description: 'common.reportID' as const, route: ROUTES.SEARCH_ADVANCED_FILTERS_REPORT_ID, }, + { + title: getFilterDisplayTitle(searchAdvancedFilters, CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT, translate), + description: 'iou.amount' as const, + route: ROUTES.SEARCH_ADVANCED_FILTERS_AMOUNT, + }, { title: getFilterDisplayTitle(searchAdvancedFilters, CONST.SEARCH.SYNTAX_FILTER_KEYS.CATEGORY, translate), description: 'common.category' as const, diff --git a/src/pages/Search/SearchFiltersAmountPage.tsx b/src/pages/Search/SearchFiltersAmountPage.tsx new file mode 100644 index 000000000000..13a8c63987e1 --- /dev/null +++ b/src/pages/Search/SearchFiltersAmountPage.tsx @@ -0,0 +1,84 @@ +import React from 'react'; +import {View} from 'react-native'; +import {useOnyx} from 'react-native-onyx'; +import AmountWithoutCurrencyForm from '@components/AmountWithoutCurrencyForm'; +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 useAutoFocusInput from '@hooks/useAutoFocusInput'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +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 SearchFiltersAmountPage() { + const styles = useThemeStyles(); + const {translate} = useLocalize(); + + const [searchAdvancedFiltersForm] = useOnyx(ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM); + const greaterThan = searchAdvancedFiltersForm?.[INPUT_IDS.GREATER_THAN]; + const lessThan = searchAdvancedFiltersForm?.[INPUT_IDS.LESS_THAN]; + const {inputCallbackRef} = useAutoFocusInput(); + + const updateAmountFilter = (values: FormOnyxValues) => { + updateAdvancedFilters(values); + Navigation.goBack(ROUTES.SEARCH_ADVANCED_FILTERS); + }; + + return ( + + { + Navigation.goBack(ROUTES.SEARCH_ADVANCED_FILTERS); + }} + /> + + + + + + + + + + ); +} + +SearchFiltersAmountPage.displayName = 'SearchFiltersAmountPage'; + +export default SearchFiltersAmountPage; diff --git a/src/types/form/SearchAdvancedFiltersForm.ts b/src/types/form/SearchAdvancedFiltersForm.ts index 2d9f05828d54..bacd6c547996 100644 --- a/src/types/form/SearchAdvancedFiltersForm.ts +++ b/src/types/form/SearchAdvancedFiltersForm.ts @@ -11,6 +11,8 @@ const INPUT_IDS = { MERCHANT: 'merchant', DESCRIPTION: 'description', REPORT_ID: 'reportID', + LESS_THAN: 'lessThan', + GREATER_THAN: 'greaterThan', TAX_RATE: 'taxRate', EXPENSE_TYPE: 'expenseType', TAG: 'tag', @@ -31,6 +33,8 @@ type SearchAdvancedFiltersForm = Form< [INPUT_IDS.MERCHANT]: string; [INPUT_IDS.DESCRIPTION]: string; [INPUT_IDS.REPORT_ID]: string; + [INPUT_IDS.LESS_THAN]: string; + [INPUT_IDS.GREATER_THAN]: string; [INPUT_IDS.KEYWORD]: string; [INPUT_IDS.TAX_RATE]: string[]; [INPUT_IDS.EXPENSE_TYPE]: string[]; From 4885ee5e66878b83d6fccb88cd58cbb2148557ab Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Wed, 14 Aug 2024 10:11:30 +0200 Subject: [PATCH 03/13] fix greaterThan and lessThan values --- src/components/AmountWithoutCurrencyForm.tsx | 8 +++++++- src/pages/Search/AdvancedSearchFilters.tsx | 2 +- src/pages/Search/SearchFiltersAmountPage.tsx | 8 ++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/components/AmountWithoutCurrencyForm.tsx b/src/components/AmountWithoutCurrencyForm.tsx index 0c24bf47e5da..f3483e640b7f 100644 --- a/src/components/AmountWithoutCurrencyForm.tsx +++ b/src/components/AmountWithoutCurrencyForm.tsx @@ -14,7 +14,7 @@ type AmountFormProps = { onInputChange?: (value: string) => void; } & Partial; -function AmountWithoutCurrencyForm({value: amount, onInputChange, ...rest}: AmountFormProps) { +function AmountWithoutCurrencyForm({value: amount, onInputChange, inputID, name, defaultValue, accessibilityLabel, role, label, ...rest}: AmountFormProps) { const {toLocaleDigit} = useLocalize(); const currentAmount = useMemo(() => (typeof amount === 'string' ? amount : ''), [amount]); @@ -43,6 +43,12 @@ function AmountWithoutCurrencyForm({value: amount, onInputChange, ...rest}: Amou , fiel if (fieldName === CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT) { const {lessThan, greaterThan} = filters; if (lessThan && greaterThan) { - return translate('search.filters.amount.between', lessThan, greaterThan); + return translate('search.filters.amount.between', greaterThan, lessThan); } if (lessThan) { return translate('search.filters.amount.lessThan', lessThan); diff --git a/src/pages/Search/SearchFiltersAmountPage.tsx b/src/pages/Search/SearchFiltersAmountPage.tsx index 13a8c63987e1..8f56cf586d2f 100644 --- a/src/pages/Search/SearchFiltersAmountPage.tsx +++ b/src/pages/Search/SearchFiltersAmountPage.tsx @@ -54,8 +54,8 @@ function SearchFiltersAmountPage() { Date: Wed, 14 Aug 2024 10:45:21 +0200 Subject: [PATCH 04/13] add build query from string logic --- src/libs/SearchUtils.ts | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/src/libs/SearchUtils.ts b/src/libs/SearchUtils.ts index f7512bf826ee..4e52cd7d313a 100644 --- a/src/libs/SearchUtils.ts +++ b/src/libs/SearchUtils.ts @@ -431,6 +431,28 @@ function buildDateFilterQuery(filterValues: Partial) return dateFilter; } +/** + * @private + * returns Date filter query string part, which needs special logic + */ +function buildAmountFilterQuery(filterValues: Partial) { + const lessThan = filterValues[FILTER_KEYS.LESS_THAN]; + const greaterThan = filterValues[FILTER_KEYS.GREATER_THAN]; + + let amountFilter = ''; + if (lessThan) { + amountFilter += `${CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT}<${lessThan}`; + } + if (lessThan && greaterThan) { + amountFilter += ' '; + } + if (greaterThan) { + amountFilter += `${CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT}>${greaterThan}`; + } + + return amountFilter; +} + function sanitizeString(str: string) { if (str.includes(' ') || str.includes(',')) { return `"${str}"`; @@ -480,14 +502,19 @@ function buildQueryStringFromFilters(filterValues: Partial Date: Wed, 14 Aug 2024 13:07:29 +0200 Subject: [PATCH 05/13] fix bug in buildQueryString --- src/libs/SearchUtils.ts | 62 ++++++++++------------ src/pages/Search/AdvancedSearchFilters.tsx | 2 +- 2 files changed, 30 insertions(+), 34 deletions(-) diff --git a/src/libs/SearchUtils.ts b/src/libs/SearchUtils.ts index 4e52cd7d313a..9de44b7c2329 100644 --- a/src/libs/SearchUtils.ts +++ b/src/libs/SearchUtils.ts @@ -476,45 +476,41 @@ function getExpenseTypeTranslationKey(expenseType: ValueOf) { - const filtersString = Object.entries(filterValues) - .map(([filterKey, filterValue]) => { - if ((filterKey === FILTER_KEYS.MERCHANT || filterKey === FILTER_KEYS.DESCRIPTION || filterKey === FILTER_KEYS.REPORT_ID || filterKey === FILTER_KEYS.KEYWORD) && filterValue) { - const keyInCorrectForm = (Object.keys(CONST.SEARCH.SYNTAX_FILTER_KEYS) as KeysOfFilterKeysObject[]).find((key) => CONST.SEARCH.SYNTAX_FILTER_KEYS[key] === filterKey); - if (keyInCorrectForm) { - return `${CONST.SEARCH.SYNTAX_FILTER_KEYS[keyInCorrectForm]}:${filterValue as string}`; - } + const filtersString = Object.entries(filterValues).map(([filterKey, filterValue]) => { + if ((filterKey === FILTER_KEYS.MERCHANT || filterKey === FILTER_KEYS.DESCRIPTION || filterKey === FILTER_KEYS.REPORT_ID || filterKey === FILTER_KEYS.KEYWORD) && filterValue) { + const keyInCorrectForm = (Object.keys(CONST.SEARCH.SYNTAX_FILTER_KEYS) as KeysOfFilterKeysObject[]).find((key) => CONST.SEARCH.SYNTAX_FILTER_KEYS[key] === filterKey); + if (keyInCorrectForm) { + return `${CONST.SEARCH.SYNTAX_FILTER_KEYS[keyInCorrectForm]}:${filterValue as string}`; } + } - if ( - (filterKey === FILTER_KEYS.CATEGORY || - filterKey === FILTER_KEYS.CARD_ID || - filterKey === FILTER_KEYS.TAX_RATE || - filterKey === FILTER_KEYS.EXPENSE_TYPE || - filterKey === FILTER_KEYS.TAG || - filterKey === FILTER_KEYS.CURRENCY) && - Array.isArray(filterValue) && - filterValue.length > 0 - ) { - const filterValueArray = filterValues[filterKey] ?? []; - const keyInCorrectForm = (Object.keys(CONST.SEARCH.SYNTAX_FILTER_KEYS) as KeysOfFilterKeysObject[]).find((key) => CONST.SEARCH.SYNTAX_FILTER_KEYS[key] === filterKey); - if (keyInCorrectForm) { - return `${CONST.SEARCH.SYNTAX_FILTER_KEYS[keyInCorrectForm]}:${filterValueArray.map(sanitizeString).join(',')}`; - } + if ( + (filterKey === FILTER_KEYS.CATEGORY || + filterKey === FILTER_KEYS.CARD_ID || + filterKey === FILTER_KEYS.TAX_RATE || + filterKey === FILTER_KEYS.EXPENSE_TYPE || + filterKey === FILTER_KEYS.TAG || + filterKey === FILTER_KEYS.CURRENCY) && + Array.isArray(filterValue) && + filterValue.length > 0 + ) { + const filterValueArray = filterValues[filterKey] ?? []; + const keyInCorrectForm = (Object.keys(CONST.SEARCH.SYNTAX_FILTER_KEYS) as KeysOfFilterKeysObject[]).find((key) => CONST.SEARCH.SYNTAX_FILTER_KEYS[key] === filterKey); + if (keyInCorrectForm) { + return `${CONST.SEARCH.SYNTAX_FILTER_KEYS[keyInCorrectForm]}:${filterValueArray.map(sanitizeString).join(',')}`; } + } - if (filterKey === FILTER_KEYS.GREATER_THAN || filterKey === FILTER_KEYS.LESS_THAN) { - return buildAmountFilterQuery(filterValues); - } + return undefined; + }); - if (filterKey === FILTER_KEYS.DATE_AFTER || filterKey === FILTER_KEYS.DATE_BEFORE) { - return buildDateFilterQuery(filterValues); - } + const dateFilter = buildDateFilterQuery(filterValues); + filtersString.push(dateFilter); + + const amountFilter = buildAmountFilterQuery(filterValues); + filtersString.push(amountFilter); - return undefined; - }) - .filter(Boolean) - .join(' '); - return filtersString; + return filtersString.filter(Boolean).join(''); } function getFilters(queryJSON: SearchQueryJSON) { diff --git a/src/pages/Search/AdvancedSearchFilters.tsx b/src/pages/Search/AdvancedSearchFilters.tsx index dc15f1d382cc..1c6ff4c78312 100644 --- a/src/pages/Search/AdvancedSearchFilters.tsx +++ b/src/pages/Search/AdvancedSearchFilters.tsx @@ -147,7 +147,7 @@ function AdvancedSearchFilters() { }, { title: getFilterDisplayTitle(searchAdvancedFilters, CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT, translate), - description: 'iou.amount' as const, + description: 'common.total' as const, route: ROUTES.SEARCH_ADVANCED_FILTERS_AMOUNT, }, { From e231cc89cb126e41041bb4389bc1718013a4bc66 Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Wed, 14 Aug 2024 13:12:42 +0200 Subject: [PATCH 06/13] fix bug --- src/libs/SearchUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/SearchUtils.ts b/src/libs/SearchUtils.ts index 9de44b7c2329..d8f544e60a1c 100644 --- a/src/libs/SearchUtils.ts +++ b/src/libs/SearchUtils.ts @@ -510,7 +510,7 @@ function buildQueryStringFromFilters(filterValues: Partial Date: Mon, 19 Aug 2024 10:34:20 +0200 Subject: [PATCH 07/13] review suggestions --- src/components/AmountWithoutCurrencyForm.tsx | 7 +++---- src/libs/SearchUtils.ts | 13 ++++--------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/components/AmountWithoutCurrencyForm.tsx b/src/components/AmountWithoutCurrencyForm.tsx index f3483e640b7f..edb823044b38 100644 --- a/src/components/AmountWithoutCurrencyForm.tsx +++ b/src/components/AmountWithoutCurrencyForm.tsx @@ -1,7 +1,6 @@ import React, {useCallback, useMemo} from 'react'; import useLocalize from '@hooks/useLocalize'; -import {replaceAllDigits, stripSpacesFromAmount, validateAmount} from '@libs/MoneyRequestUtils'; -import {replaceCommaWithDot} from '@libs/SearchUtils'; +import {replaceAllDigits, replaceCommasWithPeriod, stripSpacesFromAmount, validateAmount} from '@libs/MoneyRequestUtils'; import CONST from '@src/CONST'; import TextInput from './TextInput'; import type {BaseTextInputProps} from './TextInput/BaseTextInput/types'; @@ -28,8 +27,8 @@ function AmountWithoutCurrencyForm({value: amount, onInputChange, inputID, name, // Remove spaces from the newAmount value because Safari on iOS adds spaces when pasting a copied value // More info: https://github.com/Expensify/App/issues/16974 const newAmountWithoutSpaces = stripSpacesFromAmount(newAmount); - const replacedCommasAmount = replaceCommaWithDot(newAmountWithoutSpaces); - if (!validateAmount(replacedCommasAmount, 3)) { + const replacedCommasAmount = replaceCommasWithPeriod(newAmountWithoutSpaces); + if (!validateAmount(replacedCommasAmount, 2)) { return; } onInputChange?.(replacedCommasAmount); diff --git a/src/libs/SearchUtils.ts b/src/libs/SearchUtils.ts index d8f544e60a1c..f5f261aa8f28 100644 --- a/src/libs/SearchUtils.ts +++ b/src/libs/SearchUtils.ts @@ -74,10 +74,6 @@ function getTransactionItemCommonFormattedProperties( }; } -function replaceCommaWithDot(amount: string): string { - return amount.replace(/,/g, '.'); -} - function isSearchDataType(type: string): type is SearchDataTypes { const searchDataTypes: string[] = Object.values(CONST.SEARCH.DATA_TYPES); return searchDataTypes.includes(type); @@ -440,14 +436,14 @@ function buildAmountFilterQuery(filterValues: Partial const greaterThan = filterValues[FILTER_KEYS.GREATER_THAN]; let amountFilter = ''; - if (lessThan) { - amountFilter += `${CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT}<${lessThan}`; + if (greaterThan) { + amountFilter += `${CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT}>${greaterThan}`; } if (lessThan && greaterThan) { amountFilter += ' '; } - if (greaterThan) { - amountFilter += `${CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT}>${greaterThan}`; + if (lessThan) { + amountFilter += `${CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT}<${lessThan}`; } return amountFilter; @@ -601,5 +597,4 @@ export { normalizeQuery, shouldShowYear, getExpenseTypeTranslationKey, - replaceCommaWithDot, }; From d568ed673d7c0df183f83dab64345e573f296e47 Mon Sep 17 00:00:00 2001 From: 289Adam289 Date: Mon, 19 Aug 2024 12:15:01 +0200 Subject: [PATCH 08/13] fix focus bug --- src/components/AmountWithoutCurrencyForm.tsx | 11 ++++++++--- src/pages/Search/SearchFiltersAmountPage.tsx | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/AmountWithoutCurrencyForm.tsx b/src/components/AmountWithoutCurrencyForm.tsx index edb823044b38..4975e8e34d85 100644 --- a/src/components/AmountWithoutCurrencyForm.tsx +++ b/src/components/AmountWithoutCurrencyForm.tsx @@ -1,9 +1,10 @@ import React, {useCallback, useMemo} from 'react'; +import type {ForwardedRef} from 'react'; import useLocalize from '@hooks/useLocalize'; import {replaceAllDigits, replaceCommasWithPeriod, stripSpacesFromAmount, validateAmount} from '@libs/MoneyRequestUtils'; import CONST from '@src/CONST'; import TextInput from './TextInput'; -import type {BaseTextInputProps} from './TextInput/BaseTextInput/types'; +import type {BaseTextInputProps, BaseTextInputRef} from './TextInput/BaseTextInput/types'; type AmountFormProps = { /** Amount supplied by the FormProvider */ @@ -13,7 +14,10 @@ type AmountFormProps = { onInputChange?: (value: string) => void; } & Partial; -function AmountWithoutCurrencyForm({value: amount, onInputChange, inputID, name, defaultValue, accessibilityLabel, role, label, ...rest}: AmountFormProps) { +function AmountWithoutCurrencyForm( + {value: amount, onInputChange, inputID, name, defaultValue, accessibilityLabel, role, label, ...rest}: AmountFormProps, + ref: ForwardedRef, +) { const {toLocaleDigit} = useLocalize(); const currentAmount = useMemo(() => (typeof amount === 'string' ? amount : ''), [amount]); @@ -48,6 +52,7 @@ function AmountWithoutCurrencyForm({value: amount, onInputChange, inputID, name, defaultValue={defaultValue} accessibilityLabel={accessibilityLabel} role={role} + ref={ref} keyboardType={CONST.KEYBOARD_TYPE.DECIMAL_PAD} // eslint-disable-next-line react/jsx-props-no-spreading {...rest} @@ -57,4 +62,4 @@ function AmountWithoutCurrencyForm({value: amount, onInputChange, inputID, name, AmountWithoutCurrencyForm.displayName = 'AmountWithoutCurrencyForm'; -export default AmountWithoutCurrencyForm; +export default React.forwardRef(AmountWithoutCurrencyForm); diff --git a/src/pages/Search/SearchFiltersAmountPage.tsx b/src/pages/Search/SearchFiltersAmountPage.tsx index 8f56cf586d2f..02d0e1177b08 100644 --- a/src/pages/Search/SearchFiltersAmountPage.tsx +++ b/src/pages/Search/SearchFiltersAmountPage.tsx @@ -60,6 +60,7 @@ function SearchFiltersAmountPage() { label={translate('search.filters.amount.greaterThan')} accessibilityLabel={translate('search.filters.amount.greaterThan')} role={CONST.ROLE.PRESENTATION} + ref={inputCallbackRef} /> @@ -71,7 +72,6 @@ function SearchFiltersAmountPage() { label={translate('search.filters.amount.lessThan')} accessibilityLabel={translate('search.filters.amount.lessThan')} role={CONST.ROLE.PRESENTATION} - ref={inputCallbackRef} /> From eed752aa07ecaa7cbf56e7c678aae9a402575e3c Mon Sep 17 00:00:00 2001 From: 289Adam289 Date: Mon, 19 Aug 2024 13:21:08 +0200 Subject: [PATCH 09/13] fix merge --- src/types/form/SearchAdvancedFiltersForm.ts | 30 ++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/types/form/SearchAdvancedFiltersForm.ts b/src/types/form/SearchAdvancedFiltersForm.ts index bcd0e18015e5..6541072cae81 100644 --- a/src/types/form/SearchAdvancedFiltersForm.ts +++ b/src/types/form/SearchAdvancedFiltersForm.ts @@ -26,21 +26,21 @@ type InputID = ValueOf; type SearchAdvancedFiltersForm = Form< InputID, { - [INPUT_IDS.DATE_AFTER]: string; - [INPUT_IDS.DATE_BEFORE]: string; - [INPUT_IDS.CURRENCY]: string[]; - [INPUT_IDS.CATEGORY]: string[]; - [INPUT_IDS.POLICY_ID]: string; - [INPUT_IDS.CARD_ID]: string[]; - [INPUT_IDS.MERCHANT]: string; - [INPUT_IDS.DESCRIPTION]: string; - [INPUT_IDS.REPORT_ID]: string; - [INPUT_IDS.LESS_THAN]: string; - [INPUT_IDS.GREATER_THAN]: string; - [INPUT_IDS.KEYWORD]: string; - [INPUT_IDS.TAX_RATE]: string[]; - [INPUT_IDS.EXPENSE_TYPE]: string[]; - [INPUT_IDS.TAG]: string[]; + [FILTER_KEYS.DATE_AFTER]: string; + [FILTER_KEYS.DATE_BEFORE]: string; + [FILTER_KEYS.CURRENCY]: string[]; + [FILTER_KEYS.CATEGORY]: string[]; + [FILTER_KEYS.POLICY_ID]: string; + [FILTER_KEYS.CARD_ID]: string[]; + [FILTER_KEYS.MERCHANT]: string; + [FILTER_KEYS.DESCRIPTION]: string; + [FILTER_KEYS.REPORT_ID]: string; + [FILTER_KEYS.LESS_THAN]: string; + [FILTER_KEYS.GREATER_THAN]: string; + [FILTER_KEYS.KEYWORD]: string; + [FILTER_KEYS.TAX_RATE]: string[]; + [FILTER_KEYS.EXPENSE_TYPE]: string[]; + [FILTER_KEYS.TAG]: string[]; [FILTER_KEYS.FROM]: string[]; [FILTER_KEYS.TO]: string[]; } From a7cbfe581c25ec79745ea8c23da57eaf4bbea64e Mon Sep 17 00:00:00 2001 From: 289Adam289 Date: Wed, 21 Aug 2024 10:30:25 +0200 Subject: [PATCH 10/13] review suggestions --- src/pages/Search/AdvancedSearchFilters.tsx | 7 ++++--- src/pages/Search/SearchFiltersAmountPage.tsx | 13 ++++++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/pages/Search/AdvancedSearchFilters.tsx b/src/pages/Search/AdvancedSearchFilters.tsx index 51ef1b421274..5143a2d70008 100644 --- a/src/pages/Search/AdvancedSearchFilters.tsx +++ b/src/pages/Search/AdvancedSearchFilters.tsx @@ -12,6 +12,7 @@ import useLocalize from '@hooks/useLocalize'; import useSingleExecution from '@hooks/useSingleExecution'; import useThemeStyles from '@hooks/useThemeStyles'; import useWaitForNavigation from '@hooks/useWaitForNavigation'; +import {convertToDisplayStringWithoutCurrency} from '@libs/CurrencyUtils'; import Navigation from '@libs/Navigation/Navigation'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; import {getAllTaxRates} from '@libs/PolicyUtils'; @@ -68,13 +69,13 @@ function getFilterDisplayTitle(filters: Partial, fiel if (fieldName === CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT) { const {lessThan, greaterThan} = filters; if (lessThan && greaterThan) { - return translate('search.filters.amount.between', greaterThan, lessThan); + return translate('search.filters.amount.between', convertToDisplayStringWithoutCurrency(Number(greaterThan)), convertToDisplayStringWithoutCurrency(Number(lessThan))); } if (lessThan) { - return translate('search.filters.amount.lessThan', lessThan); + return translate('search.filters.amount.lessThan', convertToDisplayStringWithoutCurrency(Number(lessThan))); } if (greaterThan) { - return translate('search.filters.amount.greaterThan', greaterThan); + return translate('search.filters.amount.greaterThan', convertToDisplayStringWithoutCurrency(Number(greaterThan))); } } diff --git a/src/pages/Search/SearchFiltersAmountPage.tsx b/src/pages/Search/SearchFiltersAmountPage.tsx index 02d0e1177b08..e01d5e311e27 100644 --- a/src/pages/Search/SearchFiltersAmountPage.tsx +++ b/src/pages/Search/SearchFiltersAmountPage.tsx @@ -11,6 +11,7 @@ import useAutoFocusInput from '@hooks/useAutoFocusInput'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import {updateAdvancedFilters} from '@libs/actions/Search'; +import {convertToBackendAmount, convertToDisplayStringWithoutCurrency} from '@libs/CurrencyUtils'; import Navigation from '@libs/Navigation/Navigation'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -23,11 +24,17 @@ function SearchFiltersAmountPage() { const [searchAdvancedFiltersForm] = useOnyx(ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM); const greaterThan = searchAdvancedFiltersForm?.[INPUT_IDS.GREATER_THAN]; + const greaterThanFormattedAmount = greaterThan !== undefined ? convertToDisplayStringWithoutCurrency(Number(greaterThan)) : undefined; const lessThan = searchAdvancedFiltersForm?.[INPUT_IDS.LESS_THAN]; + const lessThanFormattedAmount = lessThan !== undefined ? convertToDisplayStringWithoutCurrency(Number(lessThan)) : undefined; const {inputCallbackRef} = useAutoFocusInput(); const updateAmountFilter = (values: FormOnyxValues) => { - updateAdvancedFilters(values); + const greater = values[INPUT_IDS.GREATER_THAN]; + const greaterThanBackendAmount = greater ? convertToBackendAmount(Number(greater)) : undefined; + const less = values[INPUT_IDS.LESS_THAN]; + const lessThanBackendAmount = less ? convertToBackendAmount(Number(less)) : undefined; + updateAdvancedFilters({greaterThan: greaterThanBackendAmount?.toString(), lessThan: lessThanBackendAmount?.toString()}); Navigation.goBack(ROUTES.SEARCH_ADVANCED_FILTERS); }; @@ -56,7 +63,7 @@ function SearchFiltersAmountPage() { InputComponent={AmountWithoutCurrencyForm} inputID={INPUT_IDS.GREATER_THAN} name={INPUT_IDS.GREATER_THAN} - defaultValue={greaterThan} + defaultValue={greaterThanFormattedAmount} label={translate('search.filters.amount.greaterThan')} accessibilityLabel={translate('search.filters.amount.greaterThan')} role={CONST.ROLE.PRESENTATION} @@ -68,7 +75,7 @@ function SearchFiltersAmountPage() { InputComponent={AmountWithoutCurrencyForm} inputID={INPUT_IDS.LESS_THAN} name={INPUT_IDS.LESS_THAN} - defaultValue={lessThan} + defaultValue={lessThanFormattedAmount} label={translate('search.filters.amount.lessThan')} accessibilityLabel={translate('search.filters.amount.lessThan')} role={CONST.ROLE.PRESENTATION} From 070731e983c84e7bfaa44dc4d93fd6ec1c82022d Mon Sep 17 00:00:00 2001 From: 289Adam289 Date: Wed, 21 Aug 2024 12:51:52 +0200 Subject: [PATCH 11/13] add leading zero to comma --- src/components/AmountWithoutCurrencyForm.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/AmountWithoutCurrencyForm.tsx b/src/components/AmountWithoutCurrencyForm.tsx index 4975e8e34d85..78b7c84ecb54 100644 --- a/src/components/AmountWithoutCurrencyForm.tsx +++ b/src/components/AmountWithoutCurrencyForm.tsx @@ -1,7 +1,7 @@ import React, {useCallback, useMemo} from 'react'; import type {ForwardedRef} from 'react'; import useLocalize from '@hooks/useLocalize'; -import {replaceAllDigits, replaceCommasWithPeriod, stripSpacesFromAmount, validateAmount} from '@libs/MoneyRequestUtils'; +import {addLeadingZero, replaceAllDigits, replaceCommasWithPeriod, stripSpacesFromAmount, validateAmount} from '@libs/MoneyRequestUtils'; import CONST from '@src/CONST'; import TextInput from './TextInput'; import type {BaseTextInputProps, BaseTextInputRef} from './TextInput/BaseTextInput/types'; @@ -32,10 +32,11 @@ function AmountWithoutCurrencyForm( // More info: https://github.com/Expensify/App/issues/16974 const newAmountWithoutSpaces = stripSpacesFromAmount(newAmount); const replacedCommasAmount = replaceCommasWithPeriod(newAmountWithoutSpaces); - if (!validateAmount(replacedCommasAmount, 2)) { + const withLeadingZero = addLeadingZero(replacedCommasAmount); + if (!validateAmount(withLeadingZero, 2)) { return; } - onInputChange?.(replacedCommasAmount); + onInputChange?.(withLeadingZero); }, [onInputChange], ); From 52ab72e388b68374b2131c653487fa96e1e1f6e4 Mon Sep 17 00:00:00 2001 From: 289Adam289 Date: Wed, 21 Aug 2024 14:15:32 +0200 Subject: [PATCH 12/13] remove commas from input --- src/pages/Search/SearchFiltersAmountPage.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/Search/SearchFiltersAmountPage.tsx b/src/pages/Search/SearchFiltersAmountPage.tsx index e01d5e311e27..681bb8b208e6 100644 --- a/src/pages/Search/SearchFiltersAmountPage.tsx +++ b/src/pages/Search/SearchFiltersAmountPage.tsx @@ -11,7 +11,7 @@ import useAutoFocusInput from '@hooks/useAutoFocusInput'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import {updateAdvancedFilters} from '@libs/actions/Search'; -import {convertToBackendAmount, convertToDisplayStringWithoutCurrency} from '@libs/CurrencyUtils'; +import {convertToBackendAmount, convertToFrontendAmountAsString} from '@libs/CurrencyUtils'; import Navigation from '@libs/Navigation/Navigation'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -24,9 +24,9 @@ function SearchFiltersAmountPage() { const [searchAdvancedFiltersForm] = useOnyx(ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM); const greaterThan = searchAdvancedFiltersForm?.[INPUT_IDS.GREATER_THAN]; - const greaterThanFormattedAmount = greaterThan !== undefined ? convertToDisplayStringWithoutCurrency(Number(greaterThan)) : undefined; + const greaterThanFormattedAmount = greaterThan !== undefined ? convertToFrontendAmountAsString(Number(greaterThan)) : undefined; const lessThan = searchAdvancedFiltersForm?.[INPUT_IDS.LESS_THAN]; - const lessThanFormattedAmount = lessThan !== undefined ? convertToDisplayStringWithoutCurrency(Number(lessThan)) : undefined; + const lessThanFormattedAmount = lessThan !== undefined ? convertToFrontendAmountAsString(Number(lessThan)) : undefined; const {inputCallbackRef} = useAutoFocusInput(); const updateAmountFilter = (values: FormOnyxValues) => { From c205d92c714a040dc6c27042da80f15b381a2be5 Mon Sep 17 00:00:00 2001 From: 289Adam289 Date: Wed, 21 Aug 2024 14:27:50 +0200 Subject: [PATCH 13/13] fix removing value --- src/pages/Search/SearchFiltersAmountPage.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/Search/SearchFiltersAmountPage.tsx b/src/pages/Search/SearchFiltersAmountPage.tsx index 681bb8b208e6..d7533f9ac20e 100644 --- a/src/pages/Search/SearchFiltersAmountPage.tsx +++ b/src/pages/Search/SearchFiltersAmountPage.tsx @@ -24,16 +24,16 @@ function SearchFiltersAmountPage() { const [searchAdvancedFiltersForm] = useOnyx(ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM); const greaterThan = searchAdvancedFiltersForm?.[INPUT_IDS.GREATER_THAN]; - const greaterThanFormattedAmount = greaterThan !== undefined ? convertToFrontendAmountAsString(Number(greaterThan)) : undefined; + const greaterThanFormattedAmount = greaterThan ? convertToFrontendAmountAsString(Number(greaterThan)) : undefined; const lessThan = searchAdvancedFiltersForm?.[INPUT_IDS.LESS_THAN]; - const lessThanFormattedAmount = lessThan !== undefined ? convertToFrontendAmountAsString(Number(lessThan)) : undefined; + const lessThanFormattedAmount = lessThan ? convertToFrontendAmountAsString(Number(lessThan)) : undefined; const {inputCallbackRef} = useAutoFocusInput(); const updateAmountFilter = (values: FormOnyxValues) => { const greater = values[INPUT_IDS.GREATER_THAN]; - const greaterThanBackendAmount = greater ? convertToBackendAmount(Number(greater)) : undefined; + const greaterThanBackendAmount = greater ? convertToBackendAmount(Number(greater)) : ''; const less = values[INPUT_IDS.LESS_THAN]; - const lessThanBackendAmount = less ? convertToBackendAmount(Number(less)) : undefined; + const lessThanBackendAmount = less ? convertToBackendAmount(Number(less)) : ''; updateAdvancedFilters({greaterThan: greaterThanBackendAmount?.toString(), lessThan: lessThanBackendAmount?.toString()}); Navigation.goBack(ROUTES.SEARCH_ADVANCED_FILTERS); };