Skip to content

Commit

Permalink
update variables
Browse files Browse the repository at this point in the history
  • Loading branch information
luacmartins committed Nov 6, 2024
1 parent 13f03dc commit 8f55960
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
6 changes: 3 additions & 3 deletions src/components/Search/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ type SearchQueryString = string;
type SearchQueryAST = {
type: SearchDataTypes;
status: SearchStatus;
sortBy: SearchColumnType;
sortOrder: SortOrder;
'sort-by': SearchColumnType;
'sort-order': SortOrder;
filters: ASTNode;
policyID?: string;
workspace?: string;
};

type SearchQueryJSON = {
Expand Down
22 changes: 11 additions & 11 deletions src/libs/SearchQueryUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,13 @@ function findIDFromDisplayValue(filterName: ValueOf<typeof CONST.SEARCH.SYNTAX_F
*/
function getQueryHash(query: SearchQueryJSON): number {
let orderedQuery = '';
if (query.policyID) {
orderedQuery += `${CONST.SEARCH.SYNTAX_ROOT_KEYS.POLICY_ID}:${query.policyID} `;
if (query.workspace) {
orderedQuery += `${CONST.SEARCH.SYNTAX_ROOT_KEYS.POLICY_ID}:${query.workspace} `;
}
orderedQuery += `${CONST.SEARCH.SYNTAX_ROOT_KEYS.TYPE}:${query.type}`;
orderedQuery += ` ${CONST.SEARCH.SYNTAX_ROOT_KEYS.STATUS}:${query.status}`;
orderedQuery += ` ${CONST.SEARCH.SYNTAX_ROOT_KEYS.SORT_BY}:${query.sortBy}`;
orderedQuery += ` ${CONST.SEARCH.SYNTAX_ROOT_KEYS.SORT_ORDER}:${query.sortOrder}`;
orderedQuery += ` ${CONST.SEARCH.SYNTAX_ROOT_KEYS.SORT_BY}:${query['sort-by']}`;
orderedQuery += ` ${CONST.SEARCH.SYNTAX_ROOT_KEYS.SORT_ORDER}:${query['sort-order']}`;

query.flatFilters.forEach((filter) => {
filter.filters.sort((a, b) => localeCompare(a.value.toString(), b.value.toString()));
Expand Down Expand Up @@ -301,7 +301,7 @@ function buildSearchQueryString(queryJSON?: SearchQueryJSON) {
*/
function buildQueryStringFromFilterFormValues(filterValues: Partial<SearchAdvancedFiltersForm>) {
// We separate type and status filters from other filters to maintain hashes consistency for saved searches
const {type, status, policyID, ...otherFilters} = filterValues;
const {type, status, workspace, ...otherFilters} = filterValues;
const filtersString: string[] = [];

filtersString.push(`${CONST.SEARCH.SYNTAX_ROOT_KEYS.SORT_BY}:${CONST.SEARCH.TABLE_COLUMNS.DATE}`);
Expand All @@ -317,8 +317,8 @@ function buildQueryStringFromFilterFormValues(filterValues: Partial<SearchAdvanc
filtersString.push(`${CONST.SEARCH.SYNTAX_ROOT_KEYS.STATUS}:${sanitizedStatus}`);
}

if (policyID) {
const sanitizedPolicyID = sanitizeSearchValue(policyID);
if (workspace) {
const sanitizedPolicyID = sanitizeSearchValue(workspace);
filtersString.push(`${CONST.SEARCH.SYNTAX_ROOT_KEYS.POLICY_ID}:${sanitizedPolicyID}`);
}

Expand Down Expand Up @@ -389,7 +389,7 @@ function buildFilterFormValuesFromQuery(
) {
const filters = queryJSON.flatFilters;
const filtersForm = {} as Partial<SearchAdvancedFiltersForm>;
const policyID = queryJSON.policyID;
const policyID = queryJSON.workspace;
for (const queryFilter of filters) {
const filterKey = queryFilter.key;
const filterList = queryFilter.filters;
Expand Down Expand Up @@ -471,8 +471,8 @@ function buildFilterFormValuesFromQuery(
const [statusKey] = Object.entries(CONST.SEARCH.STATUS).find(([, value]) => Object.values(value).includes(queryJSON.status)) ?? [];
filtersForm[FILTER_KEYS.STATUS] = typeKey === statusKey ? queryJSON.status : CONST.SEARCH.STATUS.EXPENSE.ALL;

if (queryJSON.policyID) {
filtersForm[FILTER_KEYS.POLICY_ID] = queryJSON.policyID;
if (queryJSON.workspace) {
filtersForm[FILTER_KEYS.POLICY_ID] = queryJSON.workspace;
}

return filtersForm;
Expand All @@ -486,7 +486,7 @@ function buildFilterFormValuesFromQuery(
* however there are several places in the app (related to WorkspaceSwitcher) that will accept only a single policyID.
*/
function getPolicyIDFromSearchQuery(queryJSON: SearchQueryJSON) {
const policyIDFilter = queryJSON.policyID;
const policyIDFilter = queryJSON.workspace;

if (!policyIDFilter) {
return;
Expand Down
30 changes: 15 additions & 15 deletions src/pages/Search/AdvancedSearchFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,77 +30,77 @@ import type {SearchAdvancedFiltersForm} from '@src/types/form';
import type {CardList, PersonalDetailsList, Report} from '@src/types/onyx';

const baseFilterConfig = {
date: {
[CONST.SEARCH.SYNTAX_FILTER_KEYS.DATE]: {
getTitle: getFilterDisplayTitle,
description: 'common.date' as const,
route: ROUTES.SEARCH_ADVANCED_FILTERS_DATE,
},
currency: {
[CONST.SEARCH.SYNTAX_FILTER_KEYS.CURRENCY]: {
getTitle: getFilterDisplayTitle,
description: 'common.currency' as const,
route: ROUTES.SEARCH_ADVANCED_FILTERS_CURRENCY,
},
merchant: {
[CONST.SEARCH.SYNTAX_FILTER_KEYS.MERCHANT]: {
getTitle: getFilterDisplayTitle,
description: 'common.merchant' as const,
route: ROUTES.SEARCH_ADVANCED_FILTERS_MERCHANT,
},
description: {
[CONST.SEARCH.SYNTAX_FILTER_KEYS.DESCRIPTION]: {
getTitle: getFilterDisplayTitle,
description: 'common.description' as const,
route: ROUTES.SEARCH_ADVANCED_FILTERS_DESCRIPTION,
},
reportid: {
[CONST.SEARCH.SYNTAX_FILTER_KEYS.REPORT_ID]: {
getTitle: getFilterDisplayTitle,
description: 'common.reportID' as const,
route: ROUTES.SEARCH_ADVANCED_FILTERS_REPORT_ID,
},
amount: {
[CONST.SEARCH.SYNTAX_FILTER_KEYS.AMOUNT]: {
getTitle: getFilterDisplayTitle,
description: 'common.total' as const,
route: ROUTES.SEARCH_ADVANCED_FILTERS_AMOUNT,
},
category: {
[CONST.SEARCH.SYNTAX_FILTER_KEYS.CATEGORY]: {
getTitle: getFilterDisplayTitle,
description: 'common.category' as const,
route: ROUTES.SEARCH_ADVANCED_FILTERS_CATEGORY,
},
keyword: {
[CONST.SEARCH.SYNTAX_FILTER_KEYS.KEYWORD]: {
getTitle: getFilterDisplayTitle,
description: 'search.filters.hasKeywords' as const,
route: ROUTES.SEARCH_ADVANCED_FILTERS_KEYWORD,
},
card: {
[CONST.SEARCH.SYNTAX_FILTER_KEYS.CARD_ID]: {
getTitle: getFilterCardDisplayTitle,
description: 'common.card' as const,
route: ROUTES.SEARCH_ADVANCED_FILTERS_CARD,
},
'tax-rate': {
[CONST.SEARCH.SYNTAX_FILTER_KEYS.TAX_RATE]: {
getTitle: getFilterTaxRateDisplayTitle,
description: 'workspace.taxes.taxRate' as const,
route: ROUTES.SEARCH_ADVANCED_FILTERS_TAX_RATE,
},
'expense-type': {
[CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPENSE_TYPE]: {
getTitle: getFilterExpenseDisplayTitle,
description: 'search.expenseType' as const,
route: ROUTES.SEARCH_ADVANCED_FILTERS_EXPENSE_TYPE,
},
tag: {
[CONST.SEARCH.SYNTAX_FILTER_KEYS.TAG]: {
getTitle: getFilterDisplayTitle,
description: 'common.tag' as const,
route: ROUTES.SEARCH_ADVANCED_FILTERS_TAG,
},
from: {
[CONST.SEARCH.SYNTAX_FILTER_KEYS.FROM]: {
getTitle: getFilterParticipantDisplayTitle,
description: 'common.from' as const,
route: ROUTES.SEARCH_ADVANCED_FILTERS_FROM,
},
to: {
[CONST.SEARCH.SYNTAX_FILTER_KEYS.TO]: {
getTitle: getFilterParticipantDisplayTitle,
description: 'common.to' as const,
route: ROUTES.SEARCH_ADVANCED_FILTERS_TO,
},
in: {
[CONST.SEARCH.SYNTAX_FILTER_KEYS.IN]: {
getTitle: getFilterInDisplayTitle,
description: 'common.in' as const,
route: ROUTES.SEARCH_ADVANCED_FILTERS_IN,
Expand Down

0 comments on commit 8f55960

Please sign in to comment.