diff --git a/src/CONST.ts b/src/CONST.ts index bfafa031dd107..234171d6df257 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -5243,6 +5243,7 @@ const CONST = { TRANSACTION: 'transaction', REPORT: 'report', EXPENSE: 'expense', + INVOICE: 'invoice', }, ACTION_TYPES: { VIEW: 'view', @@ -5272,9 +5273,11 @@ const CONST = { DRAFTS: 'drafts', FINISHED: 'finished', }, - }, - TYPE: { - EXPENSE: 'expense', + INVOICE: { + ALL: 'all', + OUTSTANDING: 'outstanding', + PAID: 'paid', + }, }, TAB: { EXPENSE: { diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 27f565929c56a..9f87d338ef14f 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -43,10 +43,6 @@ const ROUTES = { SEARCH_ADVANCED_FILTERS_DATE: 'search/filters/date', - SEARCH_ADVANCED_FILTERS_TYPE: 'search/filters/type', - - SEARCH_ADVANCED_FILTERS_STATUS: 'search/filters/status', - SEARCH_ADVANCED_FILTERS_CURRENCY: 'search/filters/currency', SEARCH_ADVANCED_FILTERS_MERCHANT: 'search/filters/merchant', diff --git a/src/SCREENS.ts b/src/SCREENS.ts index d125c9658bf2c..ff579206b1b78 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -33,8 +33,6 @@ const SCREENS = { REPORT_RHP: 'Search_Report_RHP', ADVANCED_FILTERS_RHP: 'Search_Advanced_Filters_RHP', ADVANCED_FILTERS_DATE_RHP: 'Search_Advanced_Filters_Date_RHP', - ADVANCED_FILTERS_TYPE_RHP: 'Search_Advanced_Filters_Type_RHP', - ADVANCED_FILTERS_STATUS_RHP: 'Search_Advanced_Filters_Status_RHP', ADVANCED_FILTERS_CURRENCY_RHP: 'Search_Advanced_Filters_Currency_RHP', ADVANCED_FILTERS_DESCRIPTION_RHP: 'Search_Advanced_Filters_Description_RHP', ADVANCED_FILTERS_MERCHANT_RHP: 'Search_Advanced_Filters_Merchant_RHP', diff --git a/src/components/SelectionList/SearchTableHeader.tsx b/src/components/SelectionList/SearchTableHeader.tsx index 8529d3aa34ec4..3f8abb4e1faf2 100644 --- a/src/components/SelectionList/SearchTableHeader.tsx +++ b/src/components/SelectionList/SearchTableHeader.tsx @@ -9,6 +9,7 @@ import * as SearchUtils from '@libs/SearchUtils'; import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; import type * as OnyxTypes from '@src/types/onyx'; +import type {SearchDataTypes} from '@src/types/onyx/SearchResults'; import SortableHeaderText from './SortableHeaderText'; type SearchColumnConfig = { @@ -18,7 +19,7 @@ type SearchColumnConfig = { shouldShow: (data: OnyxTypes.SearchResults['data'], metadata: OnyxTypes.SearchResults['search']) => boolean; }; -const SearchColumns: SearchColumnConfig[] = [ +const expenseHeaders: SearchColumnConfig[] = [ { columnName: CONST.SEARCH.TABLE_COLUMNS.RECEIPT, translationKey: 'common.receipt', @@ -85,6 +86,18 @@ const SearchColumns: SearchColumnConfig[] = [ }, ]; +function getSearchColumns(type: SearchDataTypes): SearchColumnConfig[] { + switch (type) { + case CONST.SEARCH.DATA_TYPES.TRANSACTION: + case CONST.SEARCH.DATA_TYPES.REPORT: + case CONST.SEARCH.DATA_TYPES.EXPENSE: + case CONST.SEARCH.DATA_TYPES.INVOICE: + return expenseHeaders; + default: + return expenseHeaders; + } +} + type SearchTableHeaderProps = { data: OnyxTypes.SearchResults['data']; metadata: OnyxTypes.SearchResults['search']; @@ -101,15 +114,16 @@ function SearchTableHeader({data, metadata, sortBy, sortOrder, onSortPress, shou const {isSmallScreenWidth, isMediumScreenWidth} = useWindowDimensions(); const {translate} = useLocalize(); const displayNarrowVersion = isMediumScreenWidth || isSmallScreenWidth; + const type = SearchUtils.getSearchType(metadata); - if (displayNarrowVersion) { + if (displayNarrowVersion || !type) { return; } return ( - {SearchColumns.map(({columnName, translationKey, shouldShow, isColumnSortable}) => { + {getSearchColumns(type).map(({columnName, translationKey, shouldShow, isColumnSortable}) => { if (!shouldShow(data, metadata)) { return null; } diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index f903da87b4e9f..40fd6905c9ecb 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -513,8 +513,6 @@ const SearchReportModalStackNavigator = createModalStackNavigator({ [SCREENS.SEARCH.ADVANCED_FILTERS_RHP]: () => require('../../../../pages/Search/SearchAdvancedFiltersPage').default, [SCREENS.SEARCH.ADVANCED_FILTERS_DATE_RHP]: () => require('../../../../pages/Search/SearchFiltersDatePage').default, - [SCREENS.SEARCH.ADVANCED_FILTERS_TYPE_RHP]: () => require('../../../../pages/Search/SearchFiltersTypePage').default, - [SCREENS.SEARCH.ADVANCED_FILTERS_STATUS_RHP]: () => require('../../../../pages/Search/SearchFiltersStatusPage').default, [SCREENS.SEARCH.ADVANCED_FILTERS_CURRENCY_RHP]: () => require('../../../../pages/Search/SearchFiltersCurrencyPage').default, [SCREENS.SEARCH.ADVANCED_FILTERS_DESCRIPTION_RHP]: () => require('../../../../pages/Search/SearchFiltersDescriptionPage').default, [SCREENS.SEARCH.ADVANCED_FILTERS_MERCHANT_RHP]: () => require('../../../../pages/Search/SearchFiltersMerchantPage').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 9a2df56690b60..4636dc3d45db4 100755 --- a/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/CENTRAL_PANE_TO_RHP_MAPPING.ts @@ -44,8 +44,6 @@ const CENTRAL_PANE_TO_RHP_MAPPING: Partial> = SCREENS.SEARCH.ADVANCED_FILTERS_RHP, SCREENS.SEARCH.ADVANCED_FILTERS_CURRENCY_RHP, SCREENS.SEARCH.ADVANCED_FILTERS_DATE_RHP, - SCREENS.SEARCH.ADVANCED_FILTERS_TYPE_RHP, - SCREENS.SEARCH.ADVANCED_FILTERS_STATUS_RHP, SCREENS.SEARCH.ADVANCED_FILTERS_DESCRIPTION_RHP, SCREENS.SEARCH.ADVANCED_FILTERS_MERCHANT_RHP, SCREENS.SEARCH.ADVANCED_FILTERS_REPORT_ID_RHP, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 52976576c0881..b17deb6cb5c5e 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -1016,8 +1016,6 @@ const config: LinkingOptions['config'] = { screens: { [SCREENS.SEARCH.ADVANCED_FILTERS_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS, [SCREENS.SEARCH.ADVANCED_FILTERS_DATE_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS_DATE, - [SCREENS.SEARCH.ADVANCED_FILTERS_TYPE_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS_TYPE, - [SCREENS.SEARCH.ADVANCED_FILTERS_STATUS_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS_STATUS, [SCREENS.SEARCH.ADVANCED_FILTERS_CURRENCY_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS_CURRENCY, [SCREENS.SEARCH.ADVANCED_FILTERS_MERCHANT_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS_MERCHANT, [SCREENS.SEARCH.ADVANCED_FILTERS_DESCRIPTION_RHP]: ROUTES.SEARCH_ADVANCED_FILTERS_DESCRIPTION, diff --git a/src/libs/SearchUtils.ts b/src/libs/SearchUtils.ts index 35328dcf6421f..54220e06a0c90 100644 --- a/src/libs/SearchUtils.ts +++ b/src/libs/SearchUtils.ts @@ -238,6 +238,7 @@ function getListItem(type: SearchDataTypes, status: SearchStatus): ListItemType< case CONST.SEARCH.DATA_TYPES.TRANSACTION: case CONST.SEARCH.DATA_TYPES.EXPENSE: case CONST.SEARCH.DATA_TYPES.REPORT: + case CONST.SEARCH.DATA_TYPES.INVOICE: return status === CONST.SEARCH.STATUS.EXPENSE.ALL ? TransactionListItem : ReportListItem; default: return TransactionListItem; @@ -249,6 +250,7 @@ function getSections(type: SearchDataTypes, status: SearchStatus, data: OnyxType case CONST.SEARCH.DATA_TYPES.TRANSACTION: case CONST.SEARCH.DATA_TYPES.EXPENSE: case CONST.SEARCH.DATA_TYPES.REPORT: + case CONST.SEARCH.DATA_TYPES.INVOICE: return status === CONST.SEARCH.STATUS.EXPENSE.ALL ? getTransactionsSections(data, metadata) : getReportSections(data, metadata); default: return getTransactionsSections(data, metadata); @@ -260,6 +262,7 @@ function getSortedSections(type: SearchDataTypes, status: SearchStatus, data: Li case CONST.SEARCH.DATA_TYPES.TRANSACTION: case CONST.SEARCH.DATA_TYPES.EXPENSE: case CONST.SEARCH.DATA_TYPES.REPORT: + case CONST.SEARCH.DATA_TYPES.INVOICE: return status === CONST.SEARCH.STATUS.EXPENSE.ALL ? getSortedTransactionData(data as TransactionListItemType[], sortBy, sortOrder) : getSortedReportData(data as ReportListItemType[]); @@ -432,14 +435,6 @@ function buildQueryStringFromFilters(filterValues: Partial { - if (filterKey === INPUT_IDS.TYPE && filterValue) { - return `${CONST.SEARCH.SYNTAX_ROOT_KEYS.TYPE}:${filterValue as string}`; - } - - if (filterKey === INPUT_IDS.STATUS && filterValue) { - return `${CONST.SEARCH.SYNTAX_ROOT_KEYS.STATUS}:${filterValue as string}`; - } - if (filterKey === INPUT_IDS.CURRENCY && Array.isArray(filterValue) && filterValue.length > 0) { return `${CONST.SEARCH.SYNTAX_FILTER_KEYS.CURRENCY}:${filterValue.join(',')}`; } diff --git a/src/pages/Search/AdvancedSearchFilters.tsx b/src/pages/Search/AdvancedSearchFilters.tsx index 7b7fe324de21b..3e623234f8152 100644 --- a/src/pages/Search/AdvancedSearchFilters.tsx +++ b/src/pages/Search/AdvancedSearchFilters.tsx @@ -79,16 +79,6 @@ function AdvancedSearchFilters() { const advancedFilters = useMemo( () => [ - { - title: getFilterDisplayTitle(searchAdvancedFilters, CONST.SEARCH.SYNTAX_ROOT_KEYS.TYPE, translate), - description: 'common.type' as const, - route: ROUTES.SEARCH_ADVANCED_FILTERS_TYPE, - }, - { - title: getFilterDisplayTitle(searchAdvancedFilters, CONST.SEARCH.SYNTAX_ROOT_KEYS.STATUS, translate), - description: 'search.filters.status' as const, - route: ROUTES.SEARCH_ADVANCED_FILTERS_STATUS, - }, { title: getFilterDisplayTitle(searchAdvancedFilters, CONST.SEARCH.SYNTAX_FILTER_KEYS.DATE, translate), description: 'common.date' as const, diff --git a/src/pages/Search/SearchFiltersStatusPage.tsx b/src/pages/Search/SearchFiltersStatusPage.tsx deleted file mode 100644 index fca6faa6fd0c4..0000000000000 --- a/src/pages/Search/SearchFiltersStatusPage.tsx +++ /dev/null @@ -1,94 +0,0 @@ -import React, {useMemo} from 'react'; -import {View} from 'react-native'; -import {useOnyx} from 'react-native-onyx'; -import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; -import type {FormOnyxValues} from '@components/Form/types'; -import HeaderWithBackButton from '@components/HeaderWithBackButton'; -import ScreenWrapper from '@components/ScreenWrapper'; -import SelectionList from '@components/SelectionList'; -import RadioListItem from '@components/SelectionList/RadioListItem'; -import useLocalize from '@hooks/useLocalize'; -import useThemeStyles from '@hooks/useThemeStyles'; -import Navigation from '@navigation/Navigation'; -import * as SearchActions from '@userActions/Search'; -import CONST from '@src/CONST'; -import ONYXKEYS from '@src/ONYXKEYS'; -import ROUTES from '@src/ROUTES'; - -function SearchFiltersStatusPage() { - const styles = useThemeStyles(); - const {translate} = useLocalize(); - - const [searchAdvancedFiltersForm] = useOnyx(ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM); - - const activeItem = searchAdvancedFiltersForm?.status; - - const filterStatusItems = useMemo( - () => [ - { - text: translate('common.all'), - value: CONST.SEARCH.STATUS.EXPENSE.ALL, - keyForList: CONST.SEARCH.STATUS.EXPENSE.ALL, - isSelected: activeItem === CONST.SEARCH.STATUS.EXPENSE.ALL, - }, - { - text: translate('common.shared'), - value: CONST.SEARCH.STATUS.EXPENSE.SHARED, - keyForList: CONST.SEARCH.STATUS.EXPENSE.SHARED, - isSelected: activeItem === CONST.SEARCH.STATUS.EXPENSE.SHARED, - }, - { - text: translate('common.drafts'), - value: CONST.SEARCH.STATUS.EXPENSE.DRAFTS, - keyForList: CONST.SEARCH.STATUS.EXPENSE.DRAFTS, - isSelected: activeItem === CONST.SEARCH.STATUS.EXPENSE.DRAFTS, - }, - { - text: translate('common.finished'), - value: CONST.SEARCH.STATUS.EXPENSE.FINISHED, - keyForList: CONST.SEARCH.STATUS.EXPENSE.FINISHED, - isSelected: activeItem === CONST.SEARCH.STATUS.EXPENSE.FINISHED, - }, - ], - [translate, activeItem], - ); - - const updateStatus = (values: Partial>) => { - SearchActions.updateAdvancedFilters(values); - Navigation.goBack(ROUTES.SEARCH_ADVANCED_FILTERS); - }; - - return ( - - - { - Navigation.goBack(ROUTES.SEARCH_ADVANCED_FILTERS); - }} - /> - - { - updateStatus({ - status: item.value, - }); - }} - initiallyFocusedOptionKey={activeItem} - shouldStopPropagation - ListItem={RadioListItem} - /> - - - - ); -} - -SearchFiltersStatusPage.displayName = 'SearchFiltersStatusPage'; - -export default SearchFiltersStatusPage; diff --git a/src/pages/Search/SearchFiltersTypePage.tsx b/src/pages/Search/SearchFiltersTypePage.tsx deleted file mode 100644 index 92b8cd96de927..0000000000000 --- a/src/pages/Search/SearchFiltersTypePage.tsx +++ /dev/null @@ -1,76 +0,0 @@ -import React, {useMemo} from 'react'; -import {View} from 'react-native'; -import {useOnyx} from 'react-native-onyx'; -import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; -import type {FormOnyxValues} from '@components/Form/types'; -import HeaderWithBackButton from '@components/HeaderWithBackButton'; -import ScreenWrapper from '@components/ScreenWrapper'; -import SelectionList from '@components/SelectionList'; -import RadioListItem from '@components/SelectionList/RadioListItem'; -import useLocalize from '@hooks/useLocalize'; -import useThemeStyles from '@hooks/useThemeStyles'; -import Navigation from '@navigation/Navigation'; -import * as SearchActions from '@userActions/Search'; -import CONST from '@src/CONST'; -import ONYXKEYS from '@src/ONYXKEYS'; -import ROUTES from '@src/ROUTES'; - -function SearchFiltersTypePage() { - const styles = useThemeStyles(); - const {translate} = useLocalize(); - - const [searchAdvancedFiltersForm] = useOnyx(ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM); - - const activeItem = searchAdvancedFiltersForm?.type; - - const filterTypeItems = useMemo( - () => [ - { - text: translate('common.expenses'), - value: CONST.SEARCH.TYPE.EXPENSE, - keyForList: CONST.SEARCH.TYPE.EXPENSE, - isSelected: activeItem === CONST.SEARCH.TYPE.EXPENSE, - }, - ], - [translate, activeItem], - ); - - const updateType = (values: Partial>) => { - SearchActions.updateAdvancedFilters(values); - Navigation.goBack(ROUTES.SEARCH_ADVANCED_FILTERS); - }; - - return ( - - - { - Navigation.goBack(ROUTES.SEARCH_ADVANCED_FILTERS); - }} - /> - - { - updateType({ - type: item.value, - }); - }} - initiallyFocusedOptionKey={activeItem} - shouldStopPropagation - ListItem={RadioListItem} - /> - - - - ); -} - -SearchFiltersTypePage.displayName = 'SearchFiltersTypePage'; - -export default SearchFiltersTypePage; diff --git a/src/types/form/SearchAdvancedFiltersForm.ts b/src/types/form/SearchAdvancedFiltersForm.ts index 1bd6286cf2e94..f407a057db526 100644 --- a/src/types/form/SearchAdvancedFiltersForm.ts +++ b/src/types/form/SearchAdvancedFiltersForm.ts @@ -2,8 +2,6 @@ import type {ValueOf} from 'type-fest'; import type Form from './Form'; const INPUT_IDS = { - TYPE: 'type', - STATUS: 'status', DATE_AFTER: 'dateAfter', DATE_BEFORE: 'dateBefore', CURRENCY: 'currency', @@ -21,10 +19,8 @@ type InputID = ValueOf; type SearchAdvancedFiltersForm = Form< InputID, { - [INPUT_IDS.TYPE]: string; [INPUT_IDS.DATE_AFTER]: string; [INPUT_IDS.DATE_BEFORE]: string; - [INPUT_IDS.STATUS]: string; [INPUT_IDS.CURRENCY]: string[]; [INPUT_IDS.CATEGORY]: string[]; [INPUT_IDS.POLICY_ID]: string;