-
Notifications
You must be signed in to change notification settings - Fork 3.2k
add tasks for new user first workspace #55302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 26 commits
1002d3b
7014f2d
c9b2f4f
61609ec
2f8e673
4921332
1063cfa
85c73bb
d83382d
06e71bc
9fa9862
e177668
b315040
bb02e14
eb483d1
8f8c6ec
c509fd5
e757aa3
385fd67
70b455f
65dd712
2eeafd0
69b6333
fa48e46
98dbb52
40c93f0
0e2565a
142545d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -424,7 +424,7 @@ function createWorkspaceWithPolicyDraftAndNavigateToIt( | |
* @param [file] Optional, avatar file for workspace | ||
*/ | ||
function savePolicyDraftByNewWorkspace(policyID?: string, policyName?: string, policyOwnerEmail = '', makeMeAdmin = false, currency = '', file?: File) { | ||
createWorkspace(policyOwnerEmail, makeMeAdmin, policyName, policyID, '', currency, file); | ||
createWorkspace(policyOwnerEmail, makeMeAdmin, policyName, policyID, CONST.ONBOARDING_CHOICES.MANAGE_TEAM, currency, file); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ishpaul777 @francoisl do you see a need for adding a comment on why we're passing MANAGE_TEAM ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no strong feelings, but it feel self explanatory if we don't typescript will yell There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No strong feelings either, though I think it might be more beneficial if we add an explanation in the doc of the function definition, in |
||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,9 +78,11 @@ import * as ReportUtils from '@libs/ReportUtils'; | |
import type {PolicySelector} from '@pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover'; | ||
import * as PaymentMethods from '@userActions/PaymentMethods'; | ||
import * as PersistedRequests from '@userActions/PersistedRequests'; | ||
import type {OnboardingPurpose} from '@src/CONST'; | ||
import CONST from '@src/CONST'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import type { | ||
IntroSelected, | ||
InvitedEmailsToAccountIDs, | ||
PersonalDetailsList, | ||
Policy, | ||
|
@@ -1698,6 +1700,12 @@ function createDraftInitialWorkspace(policyOwnerEmail = '', policyName = '', pol | |
Onyx.update(optimisticData); | ||
} | ||
|
||
let introSelected: OnyxEntry<IntroSelected>; | ||
Onyx.connect({ | ||
key: ONYXKEYS.NVP_INTRO_SELECTED, | ||
callback: (value) => (introSelected = value), | ||
}); | ||
|
||
/** | ||
* Generates onyx data for creating a new workspace | ||
* | ||
|
@@ -1709,16 +1717,18 @@ function createDraftInitialWorkspace(policyOwnerEmail = '', policyName = '', pol | |
* @param [engagementChoice] Purpose of using application selected by user in guided setup flow | ||
* @param [currency] Optional, selected currency for the workspace | ||
* @param [file] Optional, avatar file for workspace | ||
* @param [shouldAddOnboardingTasks] whether to add onboarding tasks to the workspace | ||
*/ | ||
function buildPolicyData( | ||
policyOwnerEmail = '', | ||
makeMeAdmin = false, | ||
policyName = '', | ||
policyID = generatePolicyID(), | ||
expenseReportId?: string, | ||
engagementChoice?: string, | ||
engagementChoice?: OnboardingPurpose, | ||
currency = '', | ||
file?: File, | ||
shouldAddOnboardingTasks = true, | ||
) { | ||
const workspaceName = policyName || generateDefaultWorkspaceName(policyOwnerEmail); | ||
|
||
|
@@ -1991,6 +2001,21 @@ function buildPolicyData( | |
file: clonedFile, | ||
}; | ||
|
||
if (!introSelected?.createWorkspace && engagementChoice && shouldAddOnboardingTasks) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
const onboardingData = ReportUtils.prepareOnboardingOnyxData(engagementChoice, CONST.ONBOARDING_MESSAGES[engagementChoice], adminsChatReportID, policyID); | ||
if (!onboardingData) { | ||
return {successData, optimisticData, failureData, params}; | ||
} | ||
const {guidedSetupData, optimisticData: taskOptimisticData, successData: taskSuccessData, failureData: taskFailureData} = onboardingData; | ||
|
||
params.guidedSetupData = JSON.stringify(guidedSetupData); | ||
params.engagementChoice = engagementChoice; | ||
|
||
optimisticData.push(...taskOptimisticData); | ||
successData.push(...taskSuccessData); | ||
failureData.push(...taskFailureData); | ||
} | ||
|
||
return {successData, optimisticData, failureData, params}; | ||
} | ||
|
||
|
@@ -2010,11 +2035,22 @@ function createWorkspace( | |
makeMeAdmin = false, | ||
policyName = '', | ||
policyID = generatePolicyID(), | ||
engagementChoice = '', | ||
engagementChoice: OnboardingPurpose = CONST.ONBOARDING_CHOICES.MANAGE_TEAM, | ||
currency = '', | ||
file?: File, | ||
shouldAddOnboardingTasks = true, | ||
): CreateWorkspaceParams { | ||
const {optimisticData, failureData, successData, params} = buildPolicyData(policyOwnerEmail, makeMeAdmin, policyName, policyID, undefined, engagementChoice, currency, file); | ||
const {optimisticData, failureData, successData, params} = buildPolicyData( | ||
policyOwnerEmail, | ||
makeMeAdmin, | ||
policyName, | ||
policyID, | ||
undefined, | ||
engagementChoice, | ||
currency, | ||
file, | ||
shouldAddOnboardingTasks, | ||
); | ||
API.write(WRITE_COMMANDS.CREATE_WORKSPACE, params, {optimisticData, successData, failureData}); | ||
|
||
// Publish a workspace created event if this is their first policy | ||
|
Uh oh!
There was an error while loading. Please reload this page.