From c1d524511e7e1e82f8bc2ea87fea4aff6bf51a27 Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Wed, 12 Jun 2024 15:11:18 +0200 Subject: [PATCH 1/4] Add the successData for the completed tasks --- src/libs/actions/Report.ts | 46 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 46845dce8a1e..21031101fa07 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3299,6 +3299,51 @@ function completeOnboarding( return acc; }, []); + const tasksForSuccessData = tasksData.reduce((acc, {currentTask, taskCreatedAction, completedTaskReportAction}) => { + acc.push( + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${currentTask.reportID}`, + value: { + pendingFields: { + createChat: null, + reportName: null, + description: null, + managerID: null, + }, + }, + }, + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${currentTask.reportID}`, + value: { + [taskCreatedAction.reportActionID]: taskCreatedAction as ReportAction, + }, + }, + ); + + if (completedTaskReportAction) { + acc.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${currentTask.reportID}`, + value: { + [completedTaskReportAction.reportActionID]: completedTaskReportAction as ReportAction, + }, + }); + + acc.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${currentTask.reportID}`, + value: { + stateNum: CONST.REPORT.STATE_NUM.APPROVED, + statusNum: CONST.REPORT.STATUS_NUM.APPROVED, + }, + }); + } + + return acc; + }, []); + const optimisticData: OnyxUpdate[] = [ ...tasksForOptimisticData, { @@ -3323,6 +3368,7 @@ function completeOnboarding( }, ]; const successData: OnyxUpdate[] = [ + ...tasksForSuccessData, { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, From 8ef24aeb954b9a8ea656791ade362c4bb6fd9b90 Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Wed, 12 Jun 2024 15:11:33 +0200 Subject: [PATCH 2/4] Clear the isOptimisticReport param in success data --- src/libs/actions/Report.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 21031101fa07..f8e942cf61a0 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3311,6 +3311,7 @@ function completeOnboarding( description: null, managerID: null, }, + isOptimisticReport: false, }, }, { From 9e3f74a12acde49149e647fd7773459f80345d6a Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Wed, 12 Jun 2024 15:15:17 +0200 Subject: [PATCH 3/4] Clear the pending actions --- src/libs/actions/Report.ts | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index f8e942cf61a0..759266e76314 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3301,6 +3301,13 @@ function completeOnboarding( const tasksForSuccessData = tasksData.reduce((acc, {currentTask, taskCreatedAction, completedTaskReportAction}) => { acc.push( + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, + value: { + [taskReportAction.reportAction.reportActionID]: {pendingAction: null}, + }, + }, { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${currentTask.reportID}`, @@ -3318,7 +3325,7 @@ function completeOnboarding( onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${currentTask.reportID}`, value: { - [taskCreatedAction.reportActionID]: taskCreatedAction as ReportAction, + [taskCreatedAction.reportActionID]: {pendingAction: null}, }, }, ); @@ -3328,16 +3335,7 @@ function completeOnboarding( onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${currentTask.reportID}`, value: { - [completedTaskReportAction.reportActionID]: completedTaskReportAction as ReportAction, - }, - }); - - acc.push({ - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT}${currentTask.reportID}`, - value: { - stateNum: CONST.REPORT.STATE_NUM.APPROVED, - statusNum: CONST.REPORT.STATUS_NUM.APPROVED, + [completedTaskReportAction.reportActionID]: {pendingAction: null}, }, }); } From 20621a161394a2e7f142c1d4d85bf868d235a894 Mon Sep 17 00:00:00 2001 From: Vit Horacek Date: Wed, 12 Jun 2024 15:17:06 +0200 Subject: [PATCH 4/4] Add taskReportAction to the reduce --- src/libs/actions/Report.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 759266e76314..1c2e18a885ae 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3299,7 +3299,7 @@ function completeOnboarding( return acc; }, []); - const tasksForSuccessData = tasksData.reduce((acc, {currentTask, taskCreatedAction, completedTaskReportAction}) => { + const tasksForSuccessData = tasksData.reduce((acc, {currentTask, taskCreatedAction, taskReportAction, completedTaskReportAction}) => { acc.push( { onyxMethod: Onyx.METHOD.MERGE,