Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5243,6 +5243,7 @@ const CONST = {
TRANSACTION: 'transaction',
REPORT: 'report',
EXPENSE: 'expense',
INVOICE: 'invoice',
},
ACTION_TYPES: {
VIEW: 'view',
Expand Down Expand Up @@ -5272,9 +5273,11 @@ const CONST = {
DRAFTS: 'drafts',
FINISHED: 'finished',
},
},
TYPE: {
EXPENSE: 'expense',
INVOICE: {
ALL: 'all',
OUTSTANDING: 'outstanding',
PAID: 'paid',
},
},
TAB: {
EXPENSE: {
Expand Down
4 changes: 0 additions & 4 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 0 additions & 2 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
20 changes: 17 additions & 3 deletions src/components/SelectionList/SearchTableHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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',
Expand Down Expand Up @@ -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'];
Expand All @@ -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 (
<View style={[styles.flex1]}>
<View style={[styles.flex1, styles.flexRow, styles.gap3, styles.pl4]}>
{SearchColumns.map(({columnName, translationKey, shouldShow, isColumnSortable}) => {
{getSearchColumns(type).map(({columnName, translationKey, shouldShow, isColumnSortable}) => {
if (!shouldShow(data, metadata)) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,6 @@ const SearchReportModalStackNavigator = createModalStackNavigator<SearchReportPa
const SearchAdvancedFiltersModalStackNavigator = createModalStackNavigator<SearchAdvancedFiltersParamList>({
[SCREENS.SEARCH.ADVANCED_FILTERS_RHP]: () => require<ReactComponentModule>('../../../../pages/Search/SearchAdvancedFiltersPage').default,
[SCREENS.SEARCH.ADVANCED_FILTERS_DATE_RHP]: () => require<ReactComponentModule>('../../../../pages/Search/SearchFiltersDatePage').default,
[SCREENS.SEARCH.ADVANCED_FILTERS_TYPE_RHP]: () => require<ReactComponentModule>('../../../../pages/Search/SearchFiltersTypePage').default,
[SCREENS.SEARCH.ADVANCED_FILTERS_STATUS_RHP]: () => require<ReactComponentModule>('../../../../pages/Search/SearchFiltersStatusPage').default,
[SCREENS.SEARCH.ADVANCED_FILTERS_CURRENCY_RHP]: () => require<ReactComponentModule>('../../../../pages/Search/SearchFiltersCurrencyPage').default,
[SCREENS.SEARCH.ADVANCED_FILTERS_DESCRIPTION_RHP]: () => require<ReactComponentModule>('../../../../pages/Search/SearchFiltersDescriptionPage').default,
[SCREENS.SEARCH.ADVANCED_FILTERS_MERCHANT_RHP]: () => require<ReactComponentModule>('../../../../pages/Search/SearchFiltersMerchantPage').default,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ const CENTRAL_PANE_TO_RHP_MAPPING: Partial<Record<CentralPaneName, string[]>> =
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,
Expand Down
2 changes: 0 additions & 2 deletions src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1016,8 +1016,6 @@ const config: LinkingOptions<RootStackParamList>['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,
Expand Down
11 changes: 3 additions & 8 deletions src/libs/SearchUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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[]);
Expand Down Expand Up @@ -432,14 +435,6 @@ function buildQueryStringFromFilters(filterValues: Partial<SearchAdvancedFilters
// TODO add handling of multiple values picked
const filtersString = Object.entries(filterValues)
.map(([filterKey, filterValue]) => {
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(',')}`;
}
Expand Down
10 changes: 0 additions & 10 deletions src/pages/Search/AdvancedSearchFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
94 changes: 0 additions & 94 deletions src/pages/Search/SearchFiltersStatusPage.tsx

This file was deleted.

76 changes: 0 additions & 76 deletions src/pages/Search/SearchFiltersTypePage.tsx

This file was deleted.

4 changes: 0 additions & 4 deletions src/types/form/SearchAdvancedFiltersForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -21,10 +19,8 @@ type InputID = ValueOf<typeof INPUT_IDS>;
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;
Expand Down