@@ -3,6 +3,7 @@ import {View} from 'react-native';
33import FormProvider from '@components/Form/FormProvider' ;
44import InputWrapper from '@components/Form/InputWrapper' ;
55import HeaderWithBackButton from '@components/HeaderWithBackButton' ;
6+ import type { LocalizedTranslate } from '@components/LocaleContextProvider' ;
67import ScreenWrapper from '@components/ScreenWrapper' ;
78import useFilterCardValue from '@components/Search/hooks/useFilterCardValue' ;
89import useFilterFeedValue from '@components/Search/hooks/useFilterFeedValue' ;
@@ -11,6 +12,7 @@ import useFilterTaxRateValue from '@components/Search/hooks/useFilterTaxRateValu
1112import useFilterUserValue from '@components/Search/hooks/useFilterUserValue' ;
1213import useFilterWorkspaceValue from '@components/Search/hooks/useFilterWorkspaceValue' ;
1314import { useSearchStateContext } from '@components/Search/SearchContext' ;
15+ import type { SearchQueryJSON } from '@components/Search/types' ;
1416import Text from '@components/Text' ;
1517import TextInput from '@components/TextInput' ;
1618import useAutoFocusInput from '@hooks/useAutoFocusInput' ;
@@ -19,7 +21,7 @@ import useOnyx from '@hooks/useOnyx';
1921import useThemeStyles from '@hooks/useThemeStyles' ;
2022import { saveSearch } from '@libs/actions/Search' ;
2123import Navigation from '@libs/Navigation/Navigation' ;
22- import { mapFiltersFormToLabelValueList } from '@libs/SearchUIUtils' ;
24+ import { getSearchColumnTranslationKey , mapFiltersFormToLabelValueList } from '@libs/SearchUIUtils' ;
2325import type { SearchFilter } from '@libs/SearchUIUtils' ;
2426import CONST from '@src/CONST' ;
2527import ONYXKEYS from '@src/ONYXKEYS' ;
@@ -89,6 +91,39 @@ function FilterValue({filterKey, value}: FilterValueWithKeyProps) {
8991 return value ;
9092}
9193
94+ function getAppliedDisplays ( searchAdvancedFiltersForm : Partial < SearchAdvancedFiltersForm > , queryJSON : SearchQueryJSON | undefined , translate : LocalizedTranslate ) {
95+ const appliedDisplays = [ ] ;
96+ if ( searchAdvancedFiltersForm . groupBy ) {
97+ appliedDisplays . push ( { label : translate ( 'search.display.groupBy' ) , value : translate ( `search.filters.groupBy.${ searchAdvancedFiltersForm . groupBy } ` ) } ) ;
98+ }
99+
100+ if ( searchAdvancedFiltersForm . groupCurrency ) {
101+ appliedDisplays . push ( { label : translate ( 'common.groupCurrency' ) , value : searchAdvancedFiltersForm . groupCurrency } ) ;
102+ }
103+
104+ if ( searchAdvancedFiltersForm . limit ) {
105+ appliedDisplays . push ( { label : translate ( 'search.filters.limit' ) , value : searchAdvancedFiltersForm . limit } ) ;
106+ }
107+
108+ if ( searchAdvancedFiltersForm . view ) {
109+ appliedDisplays . push ( { label : translate ( 'search.view.label' ) , value : translate ( `search.view.${ searchAdvancedFiltersForm . view } ` ) } ) ;
110+ }
111+
112+ if ( queryJSON ?. sortBy ) {
113+ appliedDisplays . push ( { label : translate ( 'search.display.sortBy' ) , value : translate ( getSearchColumnTranslationKey ( queryJSON . sortBy ) ) } ) ;
114+ }
115+
116+ if ( queryJSON ?. sortOrder ) {
117+ appliedDisplays . push ( { label : translate ( 'search.display.sortOrder' ) , value : translate ( `search.filters.sortOrder.${ queryJSON . sortOrder } ` ) } ) ;
118+ }
119+
120+ if ( searchAdvancedFiltersForm . columns ?. length ) {
121+ appliedDisplays . push ( { label : translate ( 'search.columns' ) , value : searchAdvancedFiltersForm . columns ?. map ( ( column ) => translate ( getSearchColumnTranslationKey ( column ) ) ) . join ( ', ' ) } ) ;
122+ }
123+
124+ return appliedDisplays ;
125+ }
126+
92127function SearchSavePage ( ) {
93128 const styles = useThemeStyles ( ) ;
94129 const { translate, localeCompare} = useLocalize ( ) ;
@@ -109,6 +144,7 @@ function SearchSavePage() {
109144 } ;
110145
111146 const appliedFilters = mapFiltersFormToLabelValueList ( searchAdvancedFiltersForm , undefined , undefined , translate , localeCompare ) ;
147+ const appliedDisplays = getAppliedDisplays ( searchAdvancedFiltersForm , currentSearchQueryJSON , translate ) ;
112148
113149 const { inputCallbackRef} = useAutoFocusInput ( ) ;
114150
@@ -157,6 +193,24 @@ function SearchSavePage() {
157193 ) : (
158194 < Text > { translate ( 'common.none' ) } </ Text >
159195 ) }
196+
197+ < Text style = { [ styles . textLabelSupporting , styles . mb2 , styles . mt5 ] } > { translate ( 'search.display.label' ) } :</ Text >
198+ { appliedDisplays . length > 0 ? (
199+ appliedDisplays . map ( ( filter ) => (
200+ < View
201+ style = { [ styles . flexRow ] }
202+ key = { filter . label }
203+ >
204+ < Text style = { [ styles . label , styles . ph2 ] } > { CONST . DOT_SEPARATOR } </ Text >
205+ < Text style = { [ styles . label ] } >
206+ < Text style = { [ styles . labelStrong ] } > { filter . label } : </ Text >
207+ { filter . value }
208+ </ Text >
209+ </ View >
210+ ) )
211+ ) : (
212+ < Text > { translate ( 'common.none' ) } </ Text >
213+ ) }
160214 </ FormProvider >
161215 </ ScreenWrapper >
162216 ) ;
0 commit comments