Skip to content

Commit eb08ca8

Browse files
committed
create a new type
1 parent ddf2b3a commit eb08ca8

4 files changed

Lines changed: 13 additions & 17 deletions

File tree

src/CONST/index.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6449,12 +6449,6 @@ const CONST = {
64496449
UNAPPROVED_CASH: 'unapprovedCash',
64506450
UNAPPROVED_COMPANY_CARDS: 'unapprovedCompanyCards',
64516451
},
6452-
TODO_SEARCH_KEYS: {
6453-
SUBMIT: 'submit',
6454-
APPROVE: 'approve',
6455-
PAY: 'pay',
6456-
EXPORT: 'export',
6457-
},
64586452
},
64596453

64606454
EXPENSE: {

src/libs/SearchQueryUtils.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ import {isValidDate} from './ValidationUtils';
4040

4141
type FilterKeys = keyof typeof CONST.SEARCH.SYNTAX_FILTER_KEYS;
4242

43+
type TodoSearchType = typeof CONST.SEARCH.SEARCH_KEYS.SUBMIT | typeof CONST.SEARCH.SEARCH_KEYS.APPROVE | typeof CONST.SEARCH.SEARCH_KEYS.PAY | typeof CONST.SEARCH.SEARCH_KEYS.EXPORT;
44+
4345
// This map contains chars that match each operator
4446
const operatorToCharMap = {
4547
[CONST.SEARCH.SYNTAX_OPERATORS.EQUAL_TO]: ':' as const,
@@ -960,31 +962,31 @@ function getCurrentSearchQueryJSON() {
960962
return queryJSON;
961963
}
962964

963-
function getTodoSearchQuery(action: ValueOf<typeof CONST.SEARCH.TODO_SEARCH_KEYS>, userAccountID: number | undefined) {
965+
function getTodoSearchQuery(action: TodoSearchType, userAccountID: number | undefined) {
964966
switch (action) {
965-
case CONST.SEARCH.TODO_SEARCH_KEYS.SUBMIT:
967+
case CONST.SEARCH.SEARCH_LIST.SUBMIT:
966968
return buildQueryStringFromFilterFormValues({
967969
type: CONST.SEARCH.DATA_TYPES.EXPENSE,
968970
groupBy: CONST.SEARCH.GROUP_BY.REPORTS,
969971
status: CONST.SEARCH.STATUS.EXPENSE.DRAFTS,
970972
from: [`${userAccountID}`],
971973
});
972-
case CONST.SEARCH.TODO_SEARCH_KEYS.APPROVE:
974+
case CONST.SEARCH.SEARCH_LIST.APPROVE:
973975
return buildQueryStringFromFilterFormValues({
974976
type: CONST.SEARCH.DATA_TYPES.EXPENSE,
975977
groupBy: CONST.SEARCH.GROUP_BY.REPORTS,
976978
action: CONST.SEARCH.ACTION_FILTERS.APPROVE,
977979
to: [`${userAccountID}`],
978980
});
979-
case CONST.SEARCH.TODO_SEARCH_KEYS.PAY:
981+
case CONST.SEARCH.SEARCH_LIST.PAY:
980982
return buildQueryStringFromFilterFormValues({
981983
type: CONST.SEARCH.DATA_TYPES.EXPENSE,
982984
groupBy: CONST.SEARCH.GROUP_BY.REPORTS,
983985
action: CONST.SEARCH.ACTION_FILTERS.PAY,
984986
reimbursable: CONST.SEARCH.BOOLEAN.YES,
985987
payer: userAccountID?.toString(),
986988
});
987-
case CONST.SEARCH.TODO_SEARCH_KEYS.EXPORT:
989+
case CONST.SEARCH.SEARCH_LIST.EXPORT:
988990
return buildQueryStringFromFilterFormValues({
989991
groupBy: CONST.SEARCH.GROUP_BY.REPORTS,
990992
action: CONST.SEARCH.ACTION_FILTERS.EXPORT,

src/libs/SearchUIUtils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ function getSuggestedSearches(defaultFeedID: string | undefined, accountID: numb
268268
translationPath: 'common.submit',
269269
type: CONST.SEARCH.DATA_TYPES.EXPENSE,
270270
icon: Expensicons.Pencil,
271-
searchQuery: getTodoSearchQuery(CONST.SEARCH.TODO_SEARCH_KEYS.SUBMIT, accountID),
271+
searchQuery: getTodoSearchQuery(CONST.SEARCH.SEARCH_LIST.SUBMIT, accountID),
272272
get hash() {
273273
return buildSearchQueryJSON(this.searchQuery)?.hash ?? CONST.DEFAULT_NUMBER_ID;
274274
},
@@ -278,7 +278,7 @@ function getSuggestedSearches(defaultFeedID: string | undefined, accountID: numb
278278
translationPath: 'search.bulkActions.approve',
279279
type: CONST.SEARCH.DATA_TYPES.EXPENSE,
280280
icon: Expensicons.ThumbsUp,
281-
searchQuery: getTodoSearchQuery(CONST.SEARCH.TODO_SEARCH_KEYS.APPROVE, accountID),
281+
searchQuery: getTodoSearchQuery(CONST.SEARCH.SEARCH_LIST.APPROVE, accountID),
282282
get hash() {
283283
return buildSearchQueryJSON(this.searchQuery)?.hash ?? CONST.DEFAULT_NUMBER_ID;
284284
},
@@ -288,7 +288,7 @@ function getSuggestedSearches(defaultFeedID: string | undefined, accountID: numb
288288
translationPath: 'search.bulkActions.pay',
289289
type: CONST.SEARCH.DATA_TYPES.EXPENSE,
290290
icon: Expensicons.MoneyBag,
291-
searchQuery: getTodoSearchQuery(CONST.SEARCH.TODO_SEARCH_KEYS.PAY, accountID),
291+
searchQuery: getTodoSearchQuery(CONST.SEARCH.SEARCH_LIST.PAY, accountID),
292292
get hash() {
293293
return buildSearchQueryJSON(this.searchQuery)?.hash ?? CONST.DEFAULT_NUMBER_ID;
294294
},
@@ -298,7 +298,7 @@ function getSuggestedSearches(defaultFeedID: string | undefined, accountID: numb
298298
translationPath: 'common.export',
299299
type: CONST.SEARCH.DATA_TYPES.EXPENSE,
300300
icon: Expensicons.CheckCircle,
301-
searchQuery: getTodoSearchQuery(CONST.SEARCH.TODO_SEARCH_KEYS.EXPORT, accountID),
301+
searchQuery: getTodoSearchQuery(CONST.SEARCH.SEARCH_LIST.EXPORT, accountID),
302302
get hash() {
303303
return buildSearchQueryJSON(this.searchQuery)?.hash ?? CONST.DEFAULT_NUMBER_ID;
304304
},

src/libs/actions/IOU.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11540,11 +11540,11 @@ function shouldOptimisticallyUpdateSearch(currentSearchQueryJSON: SearchQueryJSO
1154011540
return false;
1154111541
}
1154211542

11543-
const submitQueryString = getTodoSearchQuery(CONST.SEARCH.TODO_SEARCH_KEYS.SUBMIT, userAccountID);
11543+
const submitQueryString = getTodoSearchQuery(CONST.SEARCH.SEARCH_LIST.SUBMIT, userAccountID);
1154411544

1154511545
const submitQueryJSON = buildSearchQueryJSON(submitQueryString);
1154611546

11547-
const approveQueryString = getTodoSearchQuery(CONST.SEARCH.TODO_SEARCH_KEYS.APPROVE, userAccountID);
11547+
const approveQueryString = getTodoSearchQuery(CONST.SEARCH.SEARCH_LIST.APPROVE, userAccountID);
1154811548
const approveQueryJSON = buildSearchQueryJSON(approveQueryString);
1154911549

1155011550
const validSearchTypes =

0 commit comments

Comments
 (0)