diff --git a/src/components/Search/SearchPageHeader.tsx b/src/components/Search/SearchPageHeader.tsx index ecca1f00e8ce..898de61aee64 100644 --- a/src/components/Search/SearchPageHeader.tsx +++ b/src/components/Search/SearchPageHeader.tsx @@ -319,8 +319,9 @@ function SearchPageHeader({queryJSON, hash}: SearchPageHeaderProps) { } const onPress = () => { - const values = SearchUtils.buildFilterFormValuesFromQuery(queryJSON); - SearchActions.updateAdvancedFilters(values); + const filterFormValues = SearchUtils.buildFilterFormValuesFromQuery(queryJSON); + SearchActions.updateAdvancedFilters(filterFormValues); + Navigation.navigate(ROUTES.SEARCH_ADVANCED_FILTERS); }; diff --git a/src/components/Search/SearchStatusBar.tsx b/src/components/Search/SearchStatusBar.tsx index ba531382b5f0..674b2da14f22 100644 --- a/src/components/Search/SearchStatusBar.tsx +++ b/src/components/Search/SearchStatusBar.tsx @@ -17,125 +17,126 @@ import type {TranslationPaths} from '@src/languages/types'; import type {SearchDataTypes} from '@src/types/onyx/SearchResults'; import type IconAsset from '@src/types/utils/IconAsset'; import {useSearchContext} from './SearchContext'; -import type {ChatSearchStatus, ExpenseSearchStatus, InvoiceSearchStatus, SearchQueryString, SearchStatus, TripSearchStatus} from './types'; +import type {ChatSearchStatus, ExpenseSearchStatus, InvoiceSearchStatus, SearchStatus, TripSearchStatus} from './types'; type SearchStatusBarProps = { type: SearchDataTypes; status: SearchStatus; + policyID: string | undefined; onStatusChange?: () => void; }; -const expenseOptions: Array<{key: ExpenseSearchStatus; icon: IconAsset; text: TranslationPaths; query: SearchQueryString}> = [ +const expenseOptions: Array<{status: ExpenseSearchStatus; type: SearchDataTypes; icon: IconAsset; text: TranslationPaths}> = [ { - key: CONST.SEARCH.STATUS.EXPENSE.ALL, + type: CONST.SEARCH.DATA_TYPES.EXPENSE, + status: CONST.SEARCH.STATUS.EXPENSE.ALL, icon: Expensicons.All, text: 'common.all', - query: SearchUtils.buildCannedSearchQuery(CONST.SEARCH.DATA_TYPES.EXPENSE, CONST.SEARCH.STATUS.EXPENSE.ALL), }, { - key: CONST.SEARCH.STATUS.EXPENSE.DRAFTS, + type: CONST.SEARCH.DATA_TYPES.EXPENSE, + status: CONST.SEARCH.STATUS.EXPENSE.DRAFTS, icon: Expensicons.Pencil, text: 'common.drafts', - query: SearchUtils.buildCannedSearchQuery(CONST.SEARCH.DATA_TYPES.EXPENSE, CONST.SEARCH.STATUS.EXPENSE.DRAFTS), }, { - key: CONST.SEARCH.STATUS.EXPENSE.OUTSTANDING, + type: CONST.SEARCH.DATA_TYPES.EXPENSE, + status: CONST.SEARCH.STATUS.EXPENSE.OUTSTANDING, icon: Expensicons.Hourglass, text: 'common.outstanding', - query: SearchUtils.buildCannedSearchQuery(CONST.SEARCH.DATA_TYPES.EXPENSE, CONST.SEARCH.STATUS.EXPENSE.OUTSTANDING), }, { - key: CONST.SEARCH.STATUS.EXPENSE.APPROVED, + type: CONST.SEARCH.DATA_TYPES.EXPENSE, + status: CONST.SEARCH.STATUS.EXPENSE.APPROVED, icon: Expensicons.ThumbsUp, text: 'iou.approved', - query: SearchUtils.buildCannedSearchQuery(CONST.SEARCH.DATA_TYPES.EXPENSE, CONST.SEARCH.STATUS.EXPENSE.APPROVED), }, { - key: CONST.SEARCH.STATUS.EXPENSE.PAID, + type: CONST.SEARCH.DATA_TYPES.EXPENSE, + status: CONST.SEARCH.STATUS.EXPENSE.PAID, icon: Expensicons.MoneyBag, text: 'iou.settledExpensify', - query: SearchUtils.buildCannedSearchQuery(CONST.SEARCH.DATA_TYPES.EXPENSE, CONST.SEARCH.STATUS.EXPENSE.PAID), }, ]; -const invoiceOptions: Array<{key: InvoiceSearchStatus; icon: IconAsset; text: TranslationPaths; query: SearchQueryString}> = [ +const invoiceOptions: Array<{type: SearchDataTypes; status: InvoiceSearchStatus; icon: IconAsset; text: TranslationPaths}> = [ { - key: CONST.SEARCH.STATUS.INVOICE.ALL, + type: CONST.SEARCH.DATA_TYPES.INVOICE, + status: CONST.SEARCH.STATUS.INVOICE.ALL, icon: Expensicons.All, text: 'common.all', - query: SearchUtils.buildCannedSearchQuery(CONST.SEARCH.DATA_TYPES.INVOICE, CONST.SEARCH.STATUS.INVOICE.ALL), }, { - key: CONST.SEARCH.STATUS.INVOICE.OUTSTANDING, + type: CONST.SEARCH.DATA_TYPES.INVOICE, + status: CONST.SEARCH.STATUS.INVOICE.OUTSTANDING, icon: Expensicons.Hourglass, text: 'common.outstanding', - query: SearchUtils.buildCannedSearchQuery(CONST.SEARCH.DATA_TYPES.INVOICE, CONST.SEARCH.STATUS.INVOICE.OUTSTANDING), }, { - key: CONST.SEARCH.STATUS.INVOICE.PAID, + type: CONST.SEARCH.DATA_TYPES.INVOICE, + status: CONST.SEARCH.STATUS.INVOICE.PAID, icon: Expensicons.MoneyBag, text: 'iou.settledExpensify', - query: SearchUtils.buildCannedSearchQuery(CONST.SEARCH.DATA_TYPES.INVOICE, CONST.SEARCH.STATUS.INVOICE.PAID), }, ]; -const tripOptions: Array<{key: TripSearchStatus; icon: IconAsset; text: TranslationPaths; query: SearchQueryString}> = [ +const tripOptions: Array<{type: SearchDataTypes; status: TripSearchStatus; icon: IconAsset; text: TranslationPaths}> = [ { - key: CONST.SEARCH.STATUS.TRIP.ALL, + type: CONST.SEARCH.DATA_TYPES.TRIP, + status: CONST.SEARCH.STATUS.TRIP.ALL, icon: Expensicons.All, text: 'common.all', - query: SearchUtils.buildCannedSearchQuery(CONST.SEARCH.DATA_TYPES.TRIP, CONST.SEARCH.STATUS.TRIP.ALL), }, { - key: CONST.SEARCH.STATUS.TRIP.CURRENT, + type: CONST.SEARCH.DATA_TYPES.TRIP, + status: CONST.SEARCH.STATUS.TRIP.CURRENT, icon: Expensicons.Calendar, text: 'search.filters.current', - query: SearchUtils.buildCannedSearchQuery(CONST.SEARCH.DATA_TYPES.TRIP, CONST.SEARCH.STATUS.TRIP.CURRENT), }, { - key: CONST.SEARCH.STATUS.TRIP.PAST, + type: CONST.SEARCH.DATA_TYPES.TRIP, + status: CONST.SEARCH.STATUS.TRIP.PAST, icon: Expensicons.History, text: 'search.filters.past', - query: SearchUtils.buildCannedSearchQuery(CONST.SEARCH.DATA_TYPES.TRIP, CONST.SEARCH.STATUS.TRIP.PAST), }, ]; -const chatOptions: Array<{key: ChatSearchStatus; icon: IconAsset; text: TranslationPaths; query: SearchQueryString}> = [ +const chatOptions: Array<{type: SearchDataTypes; status: ChatSearchStatus; icon: IconAsset; text: TranslationPaths}> = [ { - key: CONST.SEARCH.STATUS.CHAT.ALL, + type: CONST.SEARCH.DATA_TYPES.CHAT, + status: CONST.SEARCH.STATUS.CHAT.ALL, icon: Expensicons.All, text: 'common.all', - query: SearchUtils.buildCannedSearchQuery(CONST.SEARCH.DATA_TYPES.CHAT, CONST.SEARCH.STATUS.CHAT.ALL), }, { - key: CONST.SEARCH.STATUS.CHAT.UNREAD, + type: CONST.SEARCH.DATA_TYPES.CHAT, + status: CONST.SEARCH.STATUS.CHAT.UNREAD, icon: Expensicons.ChatBubbleUnread, text: 'common.unread', - query: SearchUtils.buildCannedSearchQuery(CONST.SEARCH.DATA_TYPES.CHAT, CONST.SEARCH.STATUS.CHAT.UNREAD), }, { - key: CONST.SEARCH.STATUS.CHAT.SENT, + type: CONST.SEARCH.DATA_TYPES.CHAT, + status: CONST.SEARCH.STATUS.CHAT.SENT, icon: Expensicons.Send, text: 'common.sent', - query: SearchUtils.buildCannedSearchQuery(CONST.SEARCH.DATA_TYPES.CHAT, CONST.SEARCH.STATUS.CHAT.SENT), }, { - key: CONST.SEARCH.STATUS.CHAT.ATTACHMENTS, + type: CONST.SEARCH.DATA_TYPES.CHAT, + status: CONST.SEARCH.STATUS.CHAT.ATTACHMENTS, icon: Expensicons.Document, text: 'common.attachments', - query: SearchUtils.buildCannedSearchQuery(CONST.SEARCH.DATA_TYPES.CHAT, CONST.SEARCH.STATUS.CHAT.ATTACHMENTS), }, { - key: CONST.SEARCH.STATUS.CHAT.LINKS, + type: CONST.SEARCH.DATA_TYPES.CHAT, + status: CONST.SEARCH.STATUS.CHAT.LINKS, icon: Expensicons.Paperclip, text: 'common.links', - query: SearchUtils.buildCannedSearchQuery(CONST.SEARCH.DATA_TYPES.CHAT, CONST.SEARCH.STATUS.CHAT.LINKS), }, { - key: CONST.SEARCH.STATUS.CHAT.PINNED, + type: CONST.SEARCH.DATA_TYPES.CHAT, + status: CONST.SEARCH.STATUS.CHAT.PINNED, icon: Expensicons.Pin, text: 'search.filters.pinned', - query: SearchUtils.buildCannedSearchQuery(CONST.SEARCH.DATA_TYPES.CHAT, CONST.SEARCH.STATUS.CHAT.PINNED), }, ]; @@ -153,7 +154,7 @@ function getOptions(type: SearchDataTypes) { } } -function SearchStatusBar({type, status, onStatusChange}: SearchStatusBarProps) { +function SearchStatusBar({type, status, policyID, onStatusChange}: SearchStatusBarProps) { const {singleExecution} = useSingleExecution(); const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); @@ -178,15 +179,16 @@ function SearchStatusBar({type, status, onStatusChange}: SearchStatusBarProps) { {options.map((item, index) => { const onPress = singleExecution(() => { onStatusChange?.(); - Navigation.setParams({q: item.query}); + const query = SearchUtils.buildCannedSearchQuery({type: item.type, status: item.status, policyID}); + Navigation.setParams({q: query}); }); - const isActive = status === item.key; + const isActive = status === item.status; const isFirstItem = index === 0; const isLastItem = index === options.length - 1; return (