From 93589ed0571dd03ace0518bd2072b0b7a3cac95b Mon Sep 17 00:00:00 2001 From: Alberto Date: Thu, 14 Mar 2024 13:53:51 +0100 Subject: [PATCH 01/14] add constants --- src/CONST.ts | 15 +++++++++++++++ src/ONYXKEYS.ts | 3 +++ 2 files changed, 18 insertions(+) diff --git a/src/CONST.ts b/src/CONST.ts index fa44cda20720..69c2b502d84f 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -561,6 +561,21 @@ const CONST = { REPORT: 'report', PERSONAL_DETAIL: 'personalDetail', }, + + QUICK_ACTIONS: { + REQUEST_MANUAL: 'requestManual', + REQUEST_SCAN: 'requestScan', + REQUEST_DISTANCE: 'requestDistance', + SPLIT_MANUAL: 'splitManual', + SPLIT_SCAN: 'splitScan', + SPLIT_DISTANCE: 'splitDistance', + TRACK_MANUAL: 'trackManual', + TRACK_SCAN: 'trackScan', + TRACK_DISTANCE: 'trackDistance', + ASSIGN_TASK: 'assignTask', + SEND_MONEY: 'sendMoney', + }, + RECEIPT: { ICON_SIZE: 164, PERMISSION_GRANTED: 'granted', diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 8c48cbad561f..b19499046661 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -131,6 +131,9 @@ const ONYXKEYS = { /** The NVP with the last distance rate used per policy */ NVP_LAST_SELECTED_DISTANCE_RATES: 'lastSelectedDistanceRates', + /** The NVP with the last action taken (for the Quick Action Button) */ + NVP_QUICK_ACTION_GLOBAL_CREATE: 'nvp_quickActionGlobalCreate', + /** Does this user have push notifications enabled for this device? */ PUSH_NOTIFICATIONS_ENABLED: 'pushNotificationsEnabled', From 9e05073ce95bb781e3a0a748baf8cbe8931849a6 Mon Sep 17 00:00:00 2001 From: Alberto Date: Thu, 14 Mar 2024 15:40:57 +0100 Subject: [PATCH 02/14] Add optimistic action for requests --- src/libs/actions/IOU.ts | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index af5c40836c74..411c4bf4f731 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -231,6 +231,14 @@ Onyx.connect({ }, }); +let quickAction: OnyxEntry = {}; +Onyx.connect({ + key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, + callback: (value) => { + quickAction = value; + }, +}); + /** * Initialize money request info * @param reportID to attach the transaction to @@ -462,6 +470,10 @@ function buildOnyxDataForMoneyRequest( const outstandingChildRequest = getOutstandingChildRequest(policy ?? {}, iouReport); const clearedPendingFields = Object.fromEntries(Object.keys(transaction.pendingFields ?? {}).map((key) => [key, null])); const optimisticData: OnyxUpdate[] = []; + let newQuickAction = isScanRequest ? CONST.QUICK_ACTIONS.REQUEST_SCAN : CONST.QUICK_ACTIONS.REQUEST_MANUAL; + if (TransactionUtils.isDistanceRequest(transaction)) { + newQuickAction = CONST.QUICK_ACTIONS.REQUEST_DISTANCE; + } if (chatReport) { optimisticData.push({ @@ -497,7 +509,17 @@ function buildOnyxDataForMoneyRequest( key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`, value: transaction, }, - isNewChatReport + { + onyxMethod: Onyx.METHOD.SET, + key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, + value:{ + action: newQuickAction, + reportID: chatReport?.reportID, + isFirstQuickAction: isEmptyObject(quickAction); + }, + }, + + isNewChatReport ? { onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport?.reportID}`, From c9f9224ed830ec19c49e077e8cbd7e7a1aeeb484 Mon Sep 17 00:00:00 2001 From: Alberto Date: Thu, 14 Mar 2024 15:45:27 +0100 Subject: [PATCH 03/14] Add onyx type --- src/types/onyx/QuickAction.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/types/onyx/QuickAction.ts diff --git a/src/types/onyx/QuickAction.ts b/src/types/onyx/QuickAction.ts new file mode 100644 index 000000000000..d26482deb969 --- /dev/null +++ b/src/types/onyx/QuickAction.ts @@ -0,0 +1,18 @@ +import type {ValueOf} from 'type-fest'; +import type CONST from '@src/CONST'; + +type QuickAction = { + /** The action to take */ + action: ValueOf; + + /** ID of the report */ + reportID: string; + + /** ID of the target account for task actions */ + accountID?: number; + + /** True if it is the first quick action we store for this user */ + isFirstQuickAction?: boolean; +}; + +export default QuickAction; From a0a861c6ec583e26a563e5495ea5155e5a829d34 Mon Sep 17 00:00:00 2001 From: Alberto Date: Thu, 14 Mar 2024 17:15:53 +0100 Subject: [PATCH 04/14] add split actions --- src/libs/actions/IOU.ts | 53 +++++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 411c4bf4f731..f89c44d9d0a4 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -465,6 +465,7 @@ function buildOnyxDataForMoneyRequest( policyTagList?: OnyxEntry, policyCategories?: OnyxEntry, optimisticNextStep?: OnyxTypes.ReportNextStep | null, + isOneOnOneSplit = false, ): [OnyxUpdate[], OnyxUpdate[], OnyxUpdate[]] { const isScanRequest = TransactionUtils.isScanRequest(transaction); const outstandingChildRequest = getOutstandingChildRequest(policy ?? {}, iouReport); @@ -509,16 +510,6 @@ function buildOnyxDataForMoneyRequest( key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`, value: transaction, }, - { - onyxMethod: Onyx.METHOD.SET, - key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, - value:{ - action: newQuickAction, - reportID: chatReport?.reportID, - isFirstQuickAction: isEmptyObject(quickAction); - }, - }, - isNewChatReport ? { onyxMethod: Onyx.METHOD.SET, @@ -573,6 +564,19 @@ function buildOnyxDataForMoneyRequest( }, ); + if (!isOneOnOneSplit) { + console.log('bad'); + optimisticData.push({ + onyxMethod: Onyx.METHOD.SET, + key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, + value:{ + action: newQuickAction, + reportID: chatReport?.reportID, + isFirstQuickAction: isEmptyObject(quickAction), + }, + }); + } + if (optimisticPolicyRecentlyUsedCategories.length) { optimisticData.push({ onyxMethod: Onyx.METHOD.SET, @@ -1726,6 +1730,7 @@ function createSplitsAndOnyxData( }; } + console.log('here'); const optimisticData: OnyxUpdate[] = [ { // Use set for new reports because it doesn't exist yet, is faster, @@ -1734,6 +1739,15 @@ function createSplitsAndOnyxData( key: `${ONYXKEYS.COLLECTION.REPORT}${splitChatReport.reportID}`, value: splitChatReport, }, + { + onyxMethod: Onyx.METHOD.SET, + key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, + value:{ + action: TransactionUtils.isDistanceRequest(splitTransaction) ? CONST.QUICK_ACTIONS.SPLIT_DISTANCE : CONST.QUICK_ACTIONS.SPLIT_MANUAL, + reportID: splitChatReport.reportID, + isFirstQuickAction: isEmptyObject(quickAction), + }, + }, existingSplitChatReport ? { onyxMethod: Onyx.METHOD.MERGE, @@ -1965,6 +1979,11 @@ function createSplitsAndOnyxData( optimisticTransactionThread, optimisticCreatedActionForTransactionThread, shouldCreateNewOneOnOneIOUReport, + null, + null, + null, + null, + true, ); const individualSplit = { @@ -2189,6 +2208,15 @@ function startSplitBill( key: `${ONYXKEYS.COLLECTION.REPORT}${splitChatReport.reportID}`, value: splitChatReport, }, + { + onyxMethod: Onyx.METHOD.SET, + key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, + value:{ + action: CONST.QUICK_ACTIONS.SPLIT_SCAN, + reportID: splitChatReport.reportID, + isFirstQuickAction: isEmptyObject(quickAction), + }, + }, existingSplitChatReport ? { onyxMethod: Onyx.METHOD.MERGE, @@ -2564,6 +2592,11 @@ function completeSplitBill(chatReportID: string, reportAction: OnyxTypes.ReportA optimisticTransactionThread, optimisticCreatedActionForTransactionThread, shouldCreateNewOneOnOneIOUReport, + null, + null, + null, + null, + true, ); splits.push({ From 7270bf2612aafd8f69adc534b3f448aa737cf57f Mon Sep 17 00:00:00 2001 From: Alberto Date: Thu, 14 Mar 2024 22:00:03 +0100 Subject: [PATCH 05/14] add sendMoney --- src/libs/actions/IOU.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index f89c44d9d0a4..dbff8fb4895a 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -565,7 +565,6 @@ function buildOnyxDataForMoneyRequest( ); if (!isOneOnOneSplit) { - console.log('bad'); optimisticData.push({ onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, @@ -3329,6 +3328,15 @@ function getSendMoneyParams( lastVisibleActionCreated: reportPreviewAction.created, }, }; + const optimisticQuickActionData: OnyxUpdate = { + onyxMethod: Onyx.METHOD.SET, + key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, + value: { + action: CONST.QUICK_ACTIONS.SEND_MONEY, + reportID: chatReport.reportID, + isFirstQuickAction: isEmptyObject(quickAction), + }, + }; const optimisticIOUReportData: OnyxUpdate = { onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.REPORT}${optimisticIOUReport.reportID}`, @@ -3495,6 +3503,7 @@ function getSendMoneyParams( const optimisticData: OnyxUpdate[] = [ optimisticChatReportData, + optimisticQuickActionData, optimisticIOUReportData, optimisticChatReportActionsData, optimisticIOUReportActionsData, From 8f6416da627f78f32bd83c71f24928918629dbf3 Mon Sep 17 00:00:00 2001 From: Alberto Date: Fri, 15 Mar 2024 10:46:06 +0100 Subject: [PATCH 06/14] Add task --- src/libs/actions/Task.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index 48ab7cce9186..1a844a480c73 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -58,6 +58,14 @@ Onyx.connect({ callback: (value) => (allPersonalDetails = value), }); +let quickAction: OnyxEntry = {}; +Onyx.connect({ + key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, + callback: (value) => { + quickAction = value; + }, +}); + const allReportActions: OnyxCollection = {}; Onyx.connect({ key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, @@ -219,6 +227,19 @@ function createTaskAndNavigate( }, ); + // FOR QUICK ACTION NVP + optimisticData.push( + { + onyxMethod: Onyx.METHOD.SET, + key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, + value:{ + action: CONST.QUICK_ACTIONS.ASSIGN_TASK, + reportID: parentReportID, + isFirstQuickAction: isEmptyObject(quickAction), + }, + }, + ); + // If needed, update optimistic data for parent report action of the parent report. const optimisticParentReportData = ReportUtils.getOptimisticDataForParentReportAction(parentReportID, currentTime, CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD); if (!isEmptyObject(optimisticParentReportData)) { From b1807ee35bdcd9d1936cc7fff452f3cdad500661 Mon Sep 17 00:00:00 2001 From: Alberto Date: Fri, 15 Mar 2024 10:54:24 +0100 Subject: [PATCH 07/14] add type and target account --- src/libs/actions/Task.ts | 1 + src/types/onyx/QuickAction.ts | 2 +- src/types/onyx/index.ts | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index 1a844a480c73..b8129d8c6766 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -236,6 +236,7 @@ function createTaskAndNavigate( action: CONST.QUICK_ACTIONS.ASSIGN_TASK, reportID: parentReportID, isFirstQuickAction: isEmptyObject(quickAction), + targetAccountID: assigneeAccountID, }, }, ); diff --git a/src/types/onyx/QuickAction.ts b/src/types/onyx/QuickAction.ts index d26482deb969..310c3d1a27ba 100644 --- a/src/types/onyx/QuickAction.ts +++ b/src/types/onyx/QuickAction.ts @@ -9,7 +9,7 @@ type QuickAction = { reportID: string; /** ID of the target account for task actions */ - accountID?: number; + targetAccountID?: number; /** True if it is the first quick action we store for this user */ isFirstQuickAction?: boolean; diff --git a/src/types/onyx/index.ts b/src/types/onyx/index.ts index e3118538258e..7d129d8e2cd9 100644 --- a/src/types/onyx/index.ts +++ b/src/types/onyx/index.ts @@ -43,6 +43,7 @@ import type {PolicyTag, PolicyTagList, PolicyTags} from './PolicyTag'; import type PreferredTheme from './PreferredTheme'; import type PriorityMode from './PriorityMode'; import type PrivatePersonalDetails from './PrivatePersonalDetails'; +import type QuickAction from './QuickAction'; import type RecentlyUsedCategories from './RecentlyUsedCategories'; import type RecentlyUsedReportFields from './RecentlyUsedReportFields'; import type RecentlyUsedTags from './RecentlyUsedTags'; @@ -119,6 +120,7 @@ export type { PreferredTheme, PriorityMode, PrivatePersonalDetails, + QuickAction, RecentWaypoint, RecentlyUsedCategories, RecentlyUsedTags, From 84d9bf48fb1c98af04818643c7f441fbbc64aea7 Mon Sep 17 00:00:00 2001 From: Alberto Date: Fri, 15 Mar 2024 12:05:03 +0100 Subject: [PATCH 08/14] fix distance splits --- src/libs/actions/IOU.ts | 9 ++++++--- src/pages/iou/request/step/IOURequestStepConfirmation.js | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index dbff8fb4895a..26f63179416b 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -1674,6 +1674,7 @@ function createSplitsAndOnyxData( tag: string, existingSplitChatReportID = '', billable = false, + iouRequestType = CONST.IOU.REQUEST_TYPE.MANUAL, ): SplitsAndOnyxData { const currentUserEmailForIOUSplit = PhoneNumber.addSMSDomainIfPhoneNumber(currentUserLogin); const participantAccountIDs = participants.map((participant) => Number(participant.accountID)); @@ -1729,7 +1730,6 @@ function createSplitsAndOnyxData( }; } - console.log('here'); const optimisticData: OnyxUpdate[] = [ { // Use set for new reports because it doesn't exist yet, is faster, @@ -1742,7 +1742,7 @@ function createSplitsAndOnyxData( onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, value:{ - action: TransactionUtils.isDistanceRequest(splitTransaction) ? CONST.QUICK_ACTIONS.SPLIT_DISTANCE : CONST.QUICK_ACTIONS.SPLIT_MANUAL, + action: iouRequestType === CONST.IOU.REQUEST_TYPE.DISTANCE ? CONST.QUICK_ACTIONS.SPLIT_DISTANCE : CONST.QUICK_ACTIONS.SPLIT_MANUAL, reportID: splitChatReport.reportID, isFirstQuickAction: isEmptyObject(quickAction), }, @@ -2041,6 +2041,7 @@ function splitBill( tag: string, existingSplitChatReportID = '', billable = false, + iouRequestType = CONST.IOU.REQUEST_TYPE.MANUAL, ) { const currentCreated = DateUtils.enrichMoneyRequestTimestamp(created); const {splitData, splits, onyxData} = createSplitsAndOnyxData( @@ -2056,6 +2057,7 @@ function splitBill( tag, existingSplitChatReportID, billable, + iouRequestType, ); const parameters: SplitBillParams = { @@ -2097,9 +2099,10 @@ function splitBillAndOpenReport( category: string, tag: string, billable: boolean, + iouRequestType = CONST.IOU.REQUEST_TYPE.MANUAL, ) { const currentCreated = DateUtils.enrichMoneyRequestTimestamp(created); - const {splitData, splits, onyxData} = createSplitsAndOnyxData(participants, currentUserLogin, currentUserAccountID, amount, comment, currency, merchant, currentCreated, category, tag); + const {splitData, splits, onyxData} = createSplitsAndOnyxData(participants, currentUserLogin, currentUserAccountID, amount, comment, currency, merchant, currentCreated, category, tag, '', billable, iouRequestType); const parameters: SplitBillParams = { reportID: splitData.chatReportID, diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.js b/src/pages/iou/request/step/IOURequestStepConfirmation.js index 9904f64d6833..21ff06bf0c83 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.js +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.js @@ -286,6 +286,7 @@ function IOURequestStepConfirmation({ transaction.tag, report.reportID, transaction.billable, + transaction.iouRequestType, ); return; } @@ -304,6 +305,7 @@ function IOURequestStepConfirmation({ transaction.category, transaction.tag, transaction.billable, + transaction.iouRequestType, ); return; } From 9bbbee651ec87714ce479250e927880a8d0671e0 Mon Sep 17 00:00:00 2001 From: Alberto Date: Fri, 15 Mar 2024 12:37:28 +0100 Subject: [PATCH 09/14] prettier --- src/libs/actions/IOU.ts | 24 +++++++++++++++++++----- src/libs/actions/Task.ts | 20 +++++++++----------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 26f63179416b..c397b6849b07 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -510,7 +510,7 @@ function buildOnyxDataForMoneyRequest( key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`, value: transaction, }, - isNewChatReport + isNewChatReport ? { onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${chatReport?.reportID}`, @@ -568,7 +568,7 @@ function buildOnyxDataForMoneyRequest( optimisticData.push({ onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, - value:{ + value: { action: newQuickAction, reportID: chatReport?.reportID, isFirstQuickAction: isEmptyObject(quickAction), @@ -1741,7 +1741,7 @@ function createSplitsAndOnyxData( { onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, - value:{ + value: { action: iouRequestType === CONST.IOU.REQUEST_TYPE.DISTANCE ? CONST.QUICK_ACTIONS.SPLIT_DISTANCE : CONST.QUICK_ACTIONS.SPLIT_MANUAL, reportID: splitChatReport.reportID, isFirstQuickAction: isEmptyObject(quickAction), @@ -2102,7 +2102,21 @@ function splitBillAndOpenReport( iouRequestType = CONST.IOU.REQUEST_TYPE.MANUAL, ) { const currentCreated = DateUtils.enrichMoneyRequestTimestamp(created); - const {splitData, splits, onyxData} = createSplitsAndOnyxData(participants, currentUserLogin, currentUserAccountID, amount, comment, currency, merchant, currentCreated, category, tag, '', billable, iouRequestType); + const {splitData, splits, onyxData} = createSplitsAndOnyxData( + participants, + currentUserLogin, + currentUserAccountID, + amount, + comment, + currency, + merchant, + currentCreated, + category, + tag, + '', + billable, + iouRequestType, + ); const parameters: SplitBillParams = { reportID: splitData.chatReportID, @@ -2213,7 +2227,7 @@ function startSplitBill( { onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, - value:{ + value: { action: CONST.QUICK_ACTIONS.SPLIT_SCAN, reportID: splitChatReport.reportID, isFirstQuickAction: isEmptyObject(quickAction), diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index b8129d8c6766..b097ddf05ca5 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -228,18 +228,16 @@ function createTaskAndNavigate( ); // FOR QUICK ACTION NVP - optimisticData.push( - { - onyxMethod: Onyx.METHOD.SET, - key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, - value:{ - action: CONST.QUICK_ACTIONS.ASSIGN_TASK, - reportID: parentReportID, - isFirstQuickAction: isEmptyObject(quickAction), - targetAccountID: assigneeAccountID, - }, + optimisticData.push({ + onyxMethod: Onyx.METHOD.SET, + key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, + value: { + action: CONST.QUICK_ACTIONS.ASSIGN_TASK, + reportID: parentReportID, + isFirstQuickAction: isEmptyObject(quickAction), + targetAccountID: assigneeAccountID, }, - ); + }); // If needed, update optimistic data for parent report action of the parent report. const optimisticParentReportData = ReportUtils.getOptimisticDataForParentReportAction(parentReportID, currentTime, CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD); From 65a783ba9978fd927b32cebdb8bd59e511621f8f Mon Sep 17 00:00:00 2001 From: Alberto Date: Fri, 15 Mar 2024 12:40:14 +0100 Subject: [PATCH 10/14] typescript --- src/ONYXKEYS.ts | 1 + src/types/onyx/QuickAction.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index b19499046661..4fbe0ac1f3f1 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -590,6 +590,7 @@ type OnyxValuesMapping = { [ONYXKEYS.LOGS]: Record; [ONYXKEYS.SHOULD_STORE_LOGS]: boolean; [ONYXKEYS.CACHED_PDF_PATHS]: Record; + [ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE]: OnyxTypes.QuickAction; }; type OnyxValues = OnyxValuesMapping & OnyxCollectionValuesMapping & OnyxFormValuesMapping & OnyxFormDraftValuesMapping; diff --git a/src/types/onyx/QuickAction.ts b/src/types/onyx/QuickAction.ts index 310c3d1a27ba..6cf1af929a5c 100644 --- a/src/types/onyx/QuickAction.ts +++ b/src/types/onyx/QuickAction.ts @@ -3,10 +3,10 @@ import type CONST from '@src/CONST'; type QuickAction = { /** The action to take */ - action: ValueOf; + action?: ValueOf; /** ID of the report */ - reportID: string; + reportID?: string; /** ID of the target account for task actions */ targetAccountID?: number; From 560f3cc404c52d5e992809abf0bcdaa20cc34e1a Mon Sep 17 00:00:00 2001 From: Alberto Date: Fri, 15 Mar 2024 12:46:08 +0100 Subject: [PATCH 11/14] more typescript --- src/libs/actions/IOU.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index c397b6849b07..8f03c36ec618 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -471,7 +471,7 @@ function buildOnyxDataForMoneyRequest( const outstandingChildRequest = getOutstandingChildRequest(policy ?? {}, iouReport); const clearedPendingFields = Object.fromEntries(Object.keys(transaction.pendingFields ?? {}).map((key) => [key, null])); const optimisticData: OnyxUpdate[] = []; - let newQuickAction = isScanRequest ? CONST.QUICK_ACTIONS.REQUEST_SCAN : CONST.QUICK_ACTIONS.REQUEST_MANUAL; + let newQuickAction: string = isScanRequest ? CONST.QUICK_ACTIONS.REQUEST_SCAN : CONST.QUICK_ACTIONS.REQUEST_MANUAL; if (TransactionUtils.isDistanceRequest(transaction)) { newQuickAction = CONST.QUICK_ACTIONS.REQUEST_DISTANCE; } From ffc9fa34965f66fc63fbd3dca47c4eafba901b2a Mon Sep 17 00:00:00 2001 From: Alberto Date: Fri, 15 Mar 2024 12:53:07 +0100 Subject: [PATCH 12/14] still fighting typescript --- src/libs/actions/IOU.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 8f03c36ec618..f1a4104f1850 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -471,7 +471,7 @@ function buildOnyxDataForMoneyRequest( const outstandingChildRequest = getOutstandingChildRequest(policy ?? {}, iouReport); const clearedPendingFields = Object.fromEntries(Object.keys(transaction.pendingFields ?? {}).map((key) => [key, null])); const optimisticData: OnyxUpdate[] = []; - let newQuickAction: string = isScanRequest ? CONST.QUICK_ACTIONS.REQUEST_SCAN : CONST.QUICK_ACTIONS.REQUEST_MANUAL; + let newQuickAction: ValueOf = isScanRequest ? CONST.QUICK_ACTIONS.REQUEST_SCAN : CONST.QUICK_ACTIONS.REQUEST_MANUAL; if (TransactionUtils.isDistanceRequest(transaction)) { newQuickAction = CONST.QUICK_ACTIONS.REQUEST_DISTANCE; } From 5604d9f0aefb379c0374ceb11d4469c35df6925b Mon Sep 17 00:00:00 2001 From: Alberto Date: Fri, 15 Mar 2024 13:08:01 +0100 Subject: [PATCH 13/14] typo --- src/libs/actions/IOU.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index f1a4104f1850..dac2a8216f8a 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -471,7 +471,7 @@ function buildOnyxDataForMoneyRequest( const outstandingChildRequest = getOutstandingChildRequest(policy ?? {}, iouReport); const clearedPendingFields = Object.fromEntries(Object.keys(transaction.pendingFields ?? {}).map((key) => [key, null])); const optimisticData: OnyxUpdate[] = []; - let newQuickAction: ValueOf = isScanRequest ? CONST.QUICK_ACTIONS.REQUEST_SCAN : CONST.QUICK_ACTIONS.REQUEST_MANUAL; + let newQuickAction: ValueOf = isScanRequest ? CONST.QUICK_ACTIONS.REQUEST_SCAN : CONST.QUICK_ACTIONS.REQUEST_MANUAL; if (TransactionUtils.isDistanceRequest(transaction)) { newQuickAction = CONST.QUICK_ACTIONS.REQUEST_DISTANCE; } From 1341932c91b756e3c580c4adc65e48d7c635b530 Mon Sep 17 00:00:00 2001 From: Alberto Date: Fri, 15 Mar 2024 13:13:42 +0100 Subject: [PATCH 14/14] hopefully last one --- src/libs/actions/IOU.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index dac2a8216f8a..37b1e5c00091 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -1674,7 +1674,7 @@ function createSplitsAndOnyxData( tag: string, existingSplitChatReportID = '', billable = false, - iouRequestType = CONST.IOU.REQUEST_TYPE.MANUAL, + iouRequestType: IOURequestType = CONST.IOU.REQUEST_TYPE.MANUAL, ): SplitsAndOnyxData { const currentUserEmailForIOUSplit = PhoneNumber.addSMSDomainIfPhoneNumber(currentUserLogin); const participantAccountIDs = participants.map((participant) => Number(participant.accountID)); @@ -2041,7 +2041,7 @@ function splitBill( tag: string, existingSplitChatReportID = '', billable = false, - iouRequestType = CONST.IOU.REQUEST_TYPE.MANUAL, + iouRequestType: IOURequestType = CONST.IOU.REQUEST_TYPE.MANUAL, ) { const currentCreated = DateUtils.enrichMoneyRequestTimestamp(created); const {splitData, splits, onyxData} = createSplitsAndOnyxData( @@ -2099,7 +2099,7 @@ function splitBillAndOpenReport( category: string, tag: string, billable: boolean, - iouRequestType = CONST.IOU.REQUEST_TYPE.MANUAL, + iouRequestType: IOURequestType = CONST.IOU.REQUEST_TYPE.MANUAL, ) { const currentCreated = DateUtils.enrichMoneyRequestTimestamp(created); const {splitData, splits, onyxData} = createSplitsAndOnyxData(