Repository navigation
Add workspace upgrade flow #43822
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
Add workspace upgrade flow #43822
Changes from all commits
dcebd22
5bc393b
63ba1f8
a9695dc
17e4cab
1e36d4e
ce28f3a
0e7c440
21bbbc8
7113174
f38856b
9b01337
04ae351
1bf218a
fd7aa2b
b23453d
e95b10b
df8d035
c8bac1f
d05ccd7
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 |
|---|---|---|
|
|
@@ -353,6 +353,7 @@ export default { | |
| shared: 'Shared', | ||
| drafts: 'Drafts', | ||
| finished: 'Finished', | ||
| upgrade: 'Upgrade', | ||
| companyID: 'Company ID', | ||
| userID: 'User ID', | ||
| disable: 'Disable', | ||
|
|
@@ -2968,6 +2969,30 @@ export default { | |
| errorDescriptionPartTwo: 'reach out to Concierge', | ||
| errorDescriptionPartThree: 'for help.', | ||
| }, | ||
| upgrade: { | ||
| reportFields: { | ||
| title: 'Report fields', | ||
| description: `Report fields let you specify header-level details, distinct from tags that pertain to expenses on individual line items. These details can encompass specific project names, business trip information, locations, and more.`, | ||
| pricing: { | ||
| onlyAvailableOnPlan: 'Report fields are only available on the Control plan, starting at ', | ||
| amount: '$9 ', | ||
|
Contributor
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. |
||
| perActiveMember: 'per active member per month.', | ||
| }, | ||
| }, | ||
| note: { | ||
| upgradeWorkspace: 'Upgrade your workspace to access this feature, or', | ||
| learnMore: 'learn more', | ||
| aboutOurPlans: 'about our plans and pricing.', | ||
| }, | ||
| upgradeToUnlock: 'Unlock this feature', | ||
| completed: { | ||
| headline: `You've upgraded your workspace!`, | ||
| successMessage: (policyName: string) => `You've successfully upgraded your ${policyName} workspace to the Control plan!`, | ||
| viewSubscription: 'View your subscription', | ||
| moreDetails: 'for more details.', | ||
| gotIt: 'Got it, thanks', | ||
| }, | ||
| }, | ||
| restrictedAction: { | ||
| restricted: 'Restricted', | ||
| actionsAreCurrentlyRestricted: ({workspaceName}) => `Actions on the ${workspaceName} workspace are currently restricted`, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| type UpgradeToCorporateParams = { | ||
| policyID: string; | ||
| featureName: string; | ||
| }; | ||
|
|
||
| export default UpgradeToCorporateParams; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,7 @@ import type { | |
| UpdateWorkspaceCustomUnitAndRateParams, | ||
| UpdateWorkspaceDescriptionParams, | ||
| UpdateWorkspaceGeneralSettingsParams, | ||
| UpgradeToCorporateParams, | ||
| } from '@libs/API/parameters'; | ||
| import type UpdatePolicyAddressParams from '@libs/API/parameters/UpdatePolicyAddressParams'; | ||
| import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; | ||
|
|
@@ -3001,6 +3002,59 @@ function setForeignCurrencyDefault(policyID: string, taxCode: string) { | |
| API.write(WRITE_COMMANDS.SET_POLICY_TAXES_FOREIGN_CURRENCY_DEFAULT, parameters, onyxData); | ||
| } | ||
|
|
||
| function upgradeToCorporate(policyID: string, featureName: string) { | ||
| const policy = getPolicy(policyID); | ||
| const optimisticData: OnyxUpdate[] = [ | ||
| { | ||
| onyxMethod: Onyx.METHOD.MERGE, | ||
| key: `policy_${policyID}`, | ||
| value: { | ||
| isPendingUpgrade: true, | ||
|
Contributor
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. let's add these optimistic values and their keys in CONST if they're not there: And then add these values to the optimistic data if instant submit is enabled:
Contributor
Author
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. Handled. |
||
| type: CONST.POLICY.TYPE.CORPORATE, | ||
| maxExpenseAge: CONST.POLICY.DEFAULT_MAX_EXPENSE_AGE, | ||
| maxExpenseAmount: CONST.POLICY.DEFAULT_MAX_EXPENSE_AMOUNT, | ||
| maxExpenseAmountNoReceipt: CONST.POLICY.DEFAULT_MAX_AMOUNT_NO_RECEIPT, | ||
| glCodes: true, | ||
| ...(PolicyUtils.isInstantSubmitEnabled(policy) && { | ||
| autoReporting: true, | ||
| autoReportingFrequency: CONST.POLICY.AUTO_REPORTING_FREQUENCIES.MANUAL, | ||
| }), | ||
|
Comment on lines
+3018
to
+3021
Contributor
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 successData: OnyxUpdate[] = [ | ||
| { | ||
| onyxMethod: Onyx.METHOD.MERGE, | ||
| key: `policy_${policyID}`, | ||
| value: { | ||
| isPendingUpgrade: false, | ||
| }, | ||
| }, | ||
| ]; | ||
|
|
||
| const failureData: OnyxUpdate[] = [ | ||
| { | ||
| onyxMethod: Onyx.METHOD.MERGE, | ||
| key: `policy_${policyID}`, | ||
| value: { | ||
| isPendingUpgrade: false, | ||
| type: policy?.type, | ||
| maxExpenseAge: policy?.maxExpenseAge ?? null, | ||
| maxExpenseAmount: policy?.maxExpenseAmount ?? null, | ||
| maxExpenseAmountNoReceipt: policy?.maxExpenseAmountNoReceipt ?? null, | ||
| glCodes: policy?.glCodes ?? null, | ||
| autoReporting: policy?.autoReporting ?? null, | ||
| autoReportingFrequency: policy?.autoReportingFrequency ?? null, | ||
| }, | ||
| }, | ||
| ]; | ||
|
|
||
| const parameters: UpgradeToCorporateParams = {policyID, featureName}; | ||
|
|
||
| API.write(WRITE_COMMANDS.UPGRADE_TO_CORPORATE, parameters, {optimisticData, successData, failureData}); | ||
| } | ||
|
|
||
| function getPoliciesConnectedToSageIntacct(): Policy[] { | ||
| return Object.values(allPolicies ?? {}).filter<Policy>((policy): policy is Policy => !!policy && !!policy?.connections?.intacct); | ||
| } | ||
|
|
@@ -3067,6 +3121,7 @@ export { | |
| buildPolicyData, | ||
| enableExpensifyCard, | ||
| createPolicyExpenseChats, | ||
| upgradeToCorporate, | ||
| openPolicyExpensifyCardsPage, | ||
| requestExpensifyCardLimitIncrease, | ||
| getPoliciesConnectedToSageIntacct, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import React from 'react'; | ||
| import ConfirmationPage from '@components/ConfirmationPage'; | ||
| import TextLink from '@components/TextLink'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import Navigation from '@libs/Navigation/Navigation'; | ||
| import ROUTES from '@src/ROUTES'; | ||
|
|
||
| type Props = { | ||
| policyName: string; | ||
| policyID: string; | ||
| }; | ||
|
|
||
| function UpgradeConfirmation({policyName, policyID}: Props) { | ||
| const {translate} = useLocalize(); | ||
| const styles = useThemeStyles(); | ||
|
|
||
| return ( | ||
| <ConfirmationPage | ||
| heading={translate('workspace.upgrade.completed.headline')} | ||
| description={ | ||
| <> | ||
| {translate('workspace.upgrade.completed.successMessage', policyName)}{' '} | ||
| <TextLink | ||
| style={styles.link} | ||
| onPress={() => Navigation.navigate(ROUTES.SETTINGS_SUBSCRIPTION)} | ||
| > | ||
| {translate('workspace.upgrade.completed.viewSubscription')} | ||
| </TextLink>{' '} | ||
| {translate('workspace.upgrade.completed.moreDetails')} | ||
| </> | ||
| } | ||
| shouldShowButton | ||
| onButtonPress={() => Navigation.goBack(ROUTES.WORKSPACE_PROFILE.getRoute(policyID))} | ||
| buttonText={translate('workspace.upgrade.completed.gotIt')} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| export default UpgradeConfirmation; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coming from #54397. We should translate the system message for POLICYCHANGELOG_CORPORATE_UPGRADE.