From 750c8eec118b8e2f093f1781cce27458212d7832 Mon Sep 17 00:00:00 2001 From: Monil Bhavsar Date: Fri, 11 Oct 2024 18:47:16 +0530 Subject: [PATCH 1/2] Pass engagement choice when creating workspace --- src/libs/API/parameters/CreateWorkspaceParams.ts | 1 + src/libs/actions/Policy/Policy.ts | 8 +++++--- src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/libs/API/parameters/CreateWorkspaceParams.ts b/src/libs/API/parameters/CreateWorkspaceParams.ts index 18ef4a0e763f..91c1039169aa 100644 --- a/src/libs/API/parameters/CreateWorkspaceParams.ts +++ b/src/libs/API/parameters/CreateWorkspaceParams.ts @@ -10,6 +10,7 @@ type CreateWorkspaceParams = { expenseCreatedReportActionID: string; customUnitID: string; customUnitRateID: string; + engagementChoice?: string; }; export default CreateWorkspaceParams; diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts index ec37b2c4e1fa..329a6976752c 100644 --- a/src/libs/actions/Policy/Policy.ts +++ b/src/libs/actions/Policy/Policy.ts @@ -1588,7 +1588,7 @@ function createDraftInitialWorkspace(policyOwnerEmail = '', policyName = '', pol * @param [policyID] custom policy id we will use for created workspace * @param [expenseReportId] the reportID of the expense report that is being used to create the workspace */ -function buildPolicyData(policyOwnerEmail = '', makeMeAdmin = false, policyName = '', policyID = generatePolicyID(), expenseReportId?: string) { +function buildPolicyData(policyOwnerEmail = '', makeMeAdmin = false, policyName = '', policyID = generatePolicyID(), expenseReportId?: string, engagementChoice?: string) { const workspaceName = policyName || generateDefaultWorkspaceName(policyOwnerEmail); const {customUnits, customUnitID, customUnitRateID, outputCurrency} = buildOptimisticCustomUnits(); @@ -1805,6 +1805,7 @@ function buildPolicyData(policyOwnerEmail = '', makeMeAdmin = false, policyName expenseCreatedReportActionID, customUnitID, customUnitRateID, + engagementChoice, }; return {successData, optimisticData, failureData, params}; @@ -1817,9 +1818,10 @@ function buildPolicyData(policyOwnerEmail = '', makeMeAdmin = false, policyName * @param [makeMeAdmin] leave the calling account as an admin on the policy * @param [policyName] custom policy name we will use for created workspace * @param [policyID] custom policy id we will use for created workspace + * @param [engagementChoice] Purpose of using application selected by user in guided setup flow */ -function createWorkspace(policyOwnerEmail = '', makeMeAdmin = false, policyName = '', policyID = generatePolicyID()): CreateWorkspaceParams { - const {optimisticData, failureData, successData, params} = buildPolicyData(policyOwnerEmail, makeMeAdmin, policyName, policyID); +function createWorkspace(policyOwnerEmail = '', makeMeAdmin = false, policyName = '', policyID = generatePolicyID(), engagementChoice = ''): CreateWorkspaceParams { + const {optimisticData, failureData, successData, params} = buildPolicyData(policyOwnerEmail, makeMeAdmin, policyName, policyID, undefined, engagementChoice); API.write(WRITE_COMMANDS.CREATE_WORKSPACE, params, {optimisticData, successData, failureData}); return params; diff --git a/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx b/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx index 2dad1e6afab0..d828ca328aa1 100644 --- a/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx +++ b/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx @@ -28,6 +28,7 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue'; import type {BaseOnboardingPurposeProps} from './types'; +import {generatePolicyID} from "@userActions/Policy/Policy"; const selectableOnboardingChoices = Object.values(CONST.SELECTABLE_ONBOARDING_CHOICES); @@ -84,7 +85,7 @@ function BaseOnboardingPurpose({shouldUseNativeStyles, shouldEnableMaxHeight, ro if (choice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM) { if (!onboardingPolicyID) { - const {adminsChatReportID, policyID} = Policy.createWorkspace(undefined, true); + const {adminsChatReportID, policyID} = Policy.createWorkspace(undefined, true, '', generatePolicyID(), choice); Welcome.setOnboardingAdminsChatReportID(adminsChatReportID); Welcome.setOnboardingPolicyID(policyID); } From 5286f128d2e930ad73aa31c313c777832d910b5f Mon Sep 17 00:00:00 2001 From: Monil Bhavsar Date: Fri, 11 Oct 2024 18:56:42 +0530 Subject: [PATCH 2/2] Run prettier --- src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx b/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx index d828ca328aa1..2bdd601b4b59 100644 --- a/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx +++ b/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx @@ -21,6 +21,7 @@ import OnboardingRefManager from '@libs/OnboardingRefManager'; import type {TOnboardingRef} from '@libs/OnboardingRefManager'; import variables from '@styles/variables'; import * as Policy from '@userActions/Policy/Policy'; +import {generatePolicyID} from '@userActions/Policy/Policy'; import * as Welcome from '@userActions/Welcome'; import CONST from '@src/CONST'; import type {OnboardingPurposeType} from '@src/CONST'; @@ -28,7 +29,6 @@ import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue'; import type {BaseOnboardingPurposeProps} from './types'; -import {generatePolicyID} from "@userActions/Policy/Policy"; const selectableOnboardingChoices = Object.values(CONST.SELECTABLE_ONBOARDING_CHOICES);