From e04da3975af7b6256d1071413426bab68f7f9e4a Mon Sep 17 00:00:00 2001 From: 289Adam289 Date: Mon, 5 Aug 2024 10:19:06 +0200 Subject: [PATCH 1/3] Add keyword advanced filter for Search --- src/ROUTES.ts | 2 + src/SCREENS.ts | 1 + src/languages/en.ts | 2 + src/languages/es.ts | 2 + .../ModalStackNavigators/index.tsx | 1 + .../CENTRAL_PANE_TO_RHP_MAPPING.ts | 1 + src/libs/Navigation/linkingConfig/config.ts | 1 + src/libs/SearchUtils.ts | 4 + src/pages/Search/AdvancedSearchFilters.tsx | 5 ++ src/pages/Search/SearchFiltersKeywordPage.tsx | 74 +++++++++++++++++++ src/types/form/SearchAdvancedFiltersForm.ts | 2 + 11 files changed, 95 insertions(+) create mode 100644 src/pages/Search/SearchFiltersKeywordPage.tsx diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 4bd7a7875b3c..34bdb72b7cd6 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -55,6 +55,8 @@ const ROUTES = { SEARCH_ADVANCED_FILTERS_CATEGORY: 'search/filters/category', + SEARCH_ADVANCED_FILTERS_KEYWORD: 'search/filters/keyword', + SEARCH_REPORT: { route: 'search/view/:reportID', getRoute: (reportID: string) => `search/view/${reportID}` as const, diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 40a1ebd817fa..4f960c9221b5 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -39,6 +39,7 @@ const SCREENS = { ADVANCED_FILTERS_MERCHANT_RHP: 'Search_Advanced_Filters_Merchant_RHP', ADVANCED_FILTERS_REPORT_ID_RHP: 'Search_Advanced_Filters_ReportID_RHP', ADVANCED_FILTERS_CATEGORY_RHP: 'Search_Advanced_Filters_Category_RHP', + ADVANCED_FILTERS_KEYWORD_RHP: 'Search_Advanced_Filters_Keyword_RHP', TRANSACTION_HOLD_REASON_RHP: 'Search_Transaction_Hold_Reason_RHP', BOTTOM_TAB: 'Search_Bottom_Tab', }, diff --git a/src/languages/en.ts b/src/languages/en.ts index fe3b51a660dc..e4d12796b23a 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -3613,6 +3613,8 @@ export default { after: (date?: string) => `After ${date ?? ''}`, }, status: 'Status', + keyword: 'Keyword', + hasKeywords: 'Has keywords', }, }, genericErrorPage: { diff --git a/src/languages/es.ts b/src/languages/es.ts index 8d12a35d831d..88d06b83aef4 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -3670,6 +3670,8 @@ export default { after: (date?: string) => `Después de ${date ?? ''}`, }, status: 'Estado', + keyword: 'Palabra clave', + hasKeywords: 'Tiene palabras clave', }, }, genericErrorPage: { diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 407db0b1fdd5..a2c7fdbd90fa 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -518,6 +518,7 @@ const SearchAdvancedFiltersModalStackNavigator = createModalStackNavigator require('../../../../pages/Search/SearchFiltersMerchantPage').default, [SCREENS.SEARCH.ADVANCED_FILTERS_REPORT_ID_RHP]: () => require('../../../../pages/Search/SearchFiltersReportIDPage').default, [SCREENS.SEARCH.ADVANCED_FILTERS_CATEGORY_RHP]: () => require('../../../../pages/Search/SearchFiltersCategoryPage').default, + [SCREENS.SEARCH.ADVANCED_FILTERS_KEYWORD_RHP]: () => require('../../../../pages/Search/SearchFiltersKeywordPage').default, }); const RestrictedActionModalStackNavigator = createModalStackNavigator({ 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 758d471e2f7e..1ee658a2e5ca 100755 --- a/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts @@ -49,6 +49,7 @@ const CENTRAL_PANE_TO_RHP_MAPPING: Partial> = SCREENS.SEARCH.ADVANCED_FILTERS_MERCHANT_RHP, SCREENS.SEARCH.ADVANCED_FILTERS_REPORT_ID_RHP, SCREENS.SEARCH.ADVANCED_FILTERS_CATEGORY_RHP, + SCREENS.SEARCH.ADVANCED_FILTERS_KEYWORD_RHP, ], [SCREENS.SETTINGS.SUBSCRIPTION.ROOT]: [ SCREENS.SETTINGS.SUBSCRIPTION.ADD_PAYMENT_CARD, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 663d7bf47d75..7b76a7a4ef4d 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -1021,6 +1021,7 @@ const config: LinkingOptions['config'] = { [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_CATEGORY_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS_CATEGORY, + [SCREENS.SEARCH.ADVANCED_FILTERS_KEYWORD_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS_KEYWORD, }, }, [SCREENS.RIGHT_MODAL.RESTRICTED_ACTION]: { diff --git a/src/libs/SearchUtils.ts b/src/libs/SearchUtils.ts index a7548500de4a..8a806fc5fd2c 100644 --- a/src/libs/SearchUtils.ts +++ b/src/libs/SearchUtils.ts @@ -441,6 +441,10 @@ function buildQueryStringFromFilters(filterValues: Partial) => { + updateAdvancedFilters(values); + Navigation.goBack(ROUTES.SEARCH_ADVANCED_FILTERS); + }; + + return ( + + + { + Navigation.goBack(ROUTES.SEARCH_ADVANCED_FILTERS); + }} + /> + + + + + + + + ); +} + +SearchFiltersKeywordPage.displayName = 'SearchFiltersKeywordPage'; + +export default SearchFiltersKeywordPage; diff --git a/src/types/form/SearchAdvancedFiltersForm.ts b/src/types/form/SearchAdvancedFiltersForm.ts index 015c0b52f531..071b03c7ab69 100644 --- a/src/types/form/SearchAdvancedFiltersForm.ts +++ b/src/types/form/SearchAdvancedFiltersForm.ts @@ -11,6 +11,7 @@ const INPUT_IDS = { MERCHANT: 'merchant', DESCRIPTION: 'description', REPORT_ID: 'reportID', + KEYWORD: 'keyword', } as const; type InputID = ValueOf; @@ -27,6 +28,7 @@ type SearchAdvancedFiltersForm = Form< [INPUT_IDS.MERCHANT]: string; [INPUT_IDS.DESCRIPTION]: string; [INPUT_IDS.REPORT_ID]: string; + [INPUT_IDS.KEYWORD]: string; } >; From c6df6194ac119d72524a321f6eb0a0ba58431c46 Mon Sep 17 00:00:00 2001 From: 289Adam289 Date: Mon, 5 Aug 2024 16:05:42 +0200 Subject: [PATCH 2/3] fix spaces in ROUTES --- src/ROUTES.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 34bdb72b7cd6..de316eaab96e 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -54,7 +54,6 @@ const ROUTES = { SEARCH_ADVANCED_FILTERS_REPORT_ID: 'search/filters/reportID', SEARCH_ADVANCED_FILTERS_CATEGORY: 'search/filters/category', - SEARCH_ADVANCED_FILTERS_KEYWORD: 'search/filters/keyword', SEARCH_REPORT: { From 463f3601c38b6d3565990ae40c82bba58a0224c1 Mon Sep 17 00:00:00 2001 From: 289Adam289 Date: Thu, 8 Aug 2024 16:15:48 +0200 Subject: [PATCH 3/3] Fix search results filter string --- 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 1137ecf7674b..189ba5bc1934 100644 --- a/src/libs/SearchUtils.ts +++ b/src/libs/SearchUtils.ts @@ -509,7 +509,7 @@ function buildFilterString(filterName: string, queryFilters: QueryFilter[]) { queryFilters.forEach((queryFilter, index) => { // If the previous queryFilter has the same operator (this rule applies only to eq and neq operators) then append the current value if ((queryFilter.operator === 'eq' && queryFilters[index - 1]?.operator === 'eq') || (queryFilter.operator === 'neq' && queryFilters[index - 1]?.operator === 'neq')) { - filterValueString += `,${sanitizeString(queryFilter.value.toString())}`; + filterValueString += ` ${sanitizeString(queryFilter.value.toString())}`; } else { filterValueString += ` ${filterName}${operatorToSignMap[queryFilter.operator]}${queryFilter.value}`; }