From d726dcbfa13d8c8f1c0fe4177561dba2ce9b1a7a Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Thu, 24 Oct 2024 15:51:19 -0600 Subject: [PATCH 01/49] add consts --- src/CONST.ts | 3 +++ src/components/SelectionList/Search/ActionCell.tsx | 3 +++ src/libs/SearchUIUtils.ts | 1 + 3 files changed, 7 insertions(+) diff --git a/src/CONST.ts b/src/CONST.ts index a3df980ff5dd..f5441e6f942d 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -5644,6 +5644,9 @@ const CONST = { ACTION_TYPES: { VIEW: 'view', REVIEW: 'review', + SUBMIT: 'submit', + APPROVE: 'approve', + PAY: 'pay', DONE: 'done', PAID: 'paid', }, diff --git a/src/components/SelectionList/Search/ActionCell.tsx b/src/components/SelectionList/Search/ActionCell.tsx index faafa6159dc1..57db7e7d7969 100644 --- a/src/components/SelectionList/Search/ActionCell.tsx +++ b/src/components/SelectionList/Search/ActionCell.tsx @@ -15,6 +15,9 @@ import type {SearchTransactionAction} from '@src/types/onyx/SearchResults'; const actionTranslationsMap: Record = { view: 'common.view', review: 'common.review', + submit: 'common.submit', + approve: 'iou.approve', + pay: 'iou.pay', done: 'common.done', paid: 'iou.settledExpensify', }; diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index a7ce065a6d23..ed865d6eac2d 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -223,6 +223,7 @@ function getTransactionsSections(data: OnyxTypes.SearchResults['data'], metadata return { ...transactionItem, + action: 'submit', from, to, formattedFrom, From 2f4c9802966b65fc23163394222aaf8231216707 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Thu, 24 Oct 2024 16:26:25 -0600 Subject: [PATCH 02/49] create getAction --- src/libs/SearchUIUtils.ts | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index ed865d6eac2d..7ce8cfb44c0a 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -4,6 +4,7 @@ import ChatListItem from '@components/SelectionList/ChatListItem'; import ReportListItem from '@components/SelectionList/Search/ReportListItem'; import TransactionListItem from '@components/SelectionList/Search/TransactionListItem'; import type {ListItem, ReportActionListItemType, ReportListItemType, TransactionListItemType} from '@components/SelectionList/types'; +import * as IOU from '@libs/actions/IOU'; import * as Expensicons from '@src/components/Icon/Expensicons'; import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; @@ -11,7 +12,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type * as OnyxTypes from '@src/types/onyx'; import type SearchResults from '@src/types/onyx/SearchResults'; -import type {ListItemDataType, ListItemType, SearchDataTypes, SearchPersonalDetails, SearchReport, SearchTransaction} from '@src/types/onyx/SearchResults'; +import type {ListItemDataType, ListItemType, SearchDataTypes, SearchPersonalDetails, SearchReport, SearchTransaction, SearchTransactionAction} from '@src/types/onyx/SearchResults'; import * as CurrencyUtils from './CurrencyUtils'; import DateUtils from './DateUtils'; import {translateLocal} from './Localize'; @@ -223,7 +224,7 @@ function getTransactionsSections(data: OnyxTypes.SearchResults['data'], metadata return { ...transactionItem, - action: 'submit', + action: getAction(data, key), from, to, formattedFrom, @@ -241,6 +242,35 @@ function getTransactionsSections(data: OnyxTypes.SearchResults['data'], metadata }); } +/** + * @private + * Returns the action that can be taken on a given transaction or report + * + * Do not use directly, use only via `getSections()` facade. + */ +function getAction(data: OnyxTypes.SearchResults['data'], key: string): SearchTransactionAction { + if (!isTransactionEntry(key) && !isReportEntry(key)) { + return CONST.SEARCH.ACTION_TYPES.VIEW; + } + + return CONST.SEARCH.ACTION_TYPES.VIEW; + + // const report = isReportEntry(key) ? data[key] : data[data[key].reportID]; + // const chatReport = isReportEntry(key) ? data[key].chatReportID + // iouReport + // chatReport + // policy + // transactions + // if (IOU.canIOUBePaid()) { + // pay + // approve + // submit + // review + // view + // done + // paid +} + /** * @private * Organizes data into List Sections for display, for the ReportActionListItemType of Search Results. From 584a539d4ad69b2dc000765d87178a659931f264 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Thu, 24 Oct 2024 16:49:39 -0600 Subject: [PATCH 03/49] create canReportBeSubmitted --- .../SelectionList/Search/ActionCell.tsx | 4 +-- src/libs/SearchUIUtils.ts | 26 +++++++++++++------ src/libs/actions/IOU.ts | 21 +++++++++++++++ 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/src/components/SelectionList/Search/ActionCell.tsx b/src/components/SelectionList/Search/ActionCell.tsx index 57db7e7d7969..612f515791c0 100644 --- a/src/components/SelectionList/Search/ActionCell.tsx +++ b/src/components/SelectionList/Search/ActionCell.tsx @@ -80,7 +80,7 @@ function ActionCell({action = CONST.SEARCH.ACTION_TYPES.VIEW, isLargeScreenWidth ) : null; } - if (action === CONST.SEARCH.ACTION_TYPES.REVIEW) { + // if (action === CONST.SEARCH.ACTION_TYPES.REVIEW) { return (