Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ const ONYXKEYS = {
/** Onboarding Purpose selected by the user during Onboarding flow */
ONBOARDING_PURPOSE_SELECTED: 'onboardingPurposeSelected',

/** Onboarding policyID selected by the user during Onboarding flow */
ONBOARDING_POLICY_ID: 'onboardingPolicyID',

/** Onboarding Purpose selected by the user during Onboarding flow */
ONBOARDING_ADMINS_CHAT_REPORT_ID: 'onboardingAdminsChatReportID',

Expand Down Expand Up @@ -664,6 +667,7 @@ type OnyxValuesMapping = {
[ONYXKEYS.MAX_CANVAS_HEIGHT]: number;
[ONYXKEYS.MAX_CANVAS_WIDTH]: number;
[ONYXKEYS.ONBOARDING_PURPOSE_SELECTED]: string;
[ONYXKEYS.ONBOARDING_POLICY_ID]: string;
[ONYXKEYS.ONBOARDING_ADMINS_CHAT_REPORT_ID]: string;
[ONYXKEYS.IS_SEARCHING_FOR_REPORTS]: boolean;
[ONYXKEYS.LAST_VISITED_PATH]: string | undefined;
Expand Down
3 changes: 2 additions & 1 deletion src/libs/actions/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1611,10 +1611,11 @@ function clearAvatarErrors(policyID: string) {
* Optimistically update the general settings. Set the general settings as pending until the response succeeds.
* If the response fails set a general error message. Clear the error message when updating.
*/
function updateGeneralSettings(policyID: string, name: string, currency: string) {
function updateGeneralSettings(policyID: string, name: string, currencyValue?: string) {
const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`];
const distanceUnit = Object.values(policy?.customUnits ?? {}).find((unit) => unit.name === CONST.CUSTOM_UNITS.NAME_DISTANCE);
const customUnitID = distanceUnit?.customUnitID;
const currency = currencyValue ?? policy?.outputCurrency ?? CONST.CURRENCY.USD;

if (!policy) {
return;
Expand Down
6 changes: 5 additions & 1 deletion src/libs/actions/Welcome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ function setOnboardingAdminsChatReportID(adminsChatReportID?: string) {
Onyx.set(ONYXKEYS.ONBOARDING_ADMINS_CHAT_REPORT_ID, adminsChatReportID ?? null);
}

function setOnboardingPolicyID(policyID?: string) {
Onyx.set(ONYXKEYS.ONBOARDING_POLICY_ID, policyID ?? null);
}

Onyx.connect({
key: ONYXKEYS.NVP_ONBOARDING,
initWithStoredValues: false,
Expand Down Expand Up @@ -134,4 +138,4 @@ function resetAllChecks() {
isLoadingReportData = true;
}

export {onServerDataReady, isOnboardingFlowCompleted, setOnboardingPurposeSelected, resetAllChecks, setOnboardingAdminsChatReportID};
export {onServerDataReady, isOnboardingFlowCompleted, setOnboardingPurposeSelected, resetAllChecks, setOnboardingAdminsChatReportID, setOnboardingPolicyID};
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ function BaseOnboardingPersonalDetails({currentUserPersonalDetails, shouldUseNat
);

Welcome.setOnboardingAdminsChatReportID();
Welcome.setOnboardingPolicyID();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cretadn22 Do you recall why or if this clean up is necessary? Or was it done just for consistency with setOnboardingAdminsChatReportID?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's correct, if I’m recalling correctly.


Navigation.dismissModal();

Expand Down
17 changes: 13 additions & 4 deletions src/pages/OnboardingWork/BaseOnboardingWork.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import type {BaseOnboardingWorkOnyxProps, BaseOnboardingWorkProps} from './types

const OPEN_WORK_PAGE_PURPOSES = [CONST.ONBOARDING_CHOICES.MANAGE_TEAM];

function BaseOnboardingWork({shouldUseNativeStyles, onboardingPurposeSelected}: BaseOnboardingWorkProps) {
function BaseOnboardingWork({shouldUseNativeStyles, onboardingPurposeSelected, onboardingPolicyID}: BaseOnboardingWorkProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const {isSmallScreenWidth} = useWindowDimensions();
Expand All @@ -41,11 +41,17 @@ function BaseOnboardingWork({shouldUseNativeStyles, onboardingPurposeSelected}:
return;
}
const work = values.work.trim();
const {adminsChatReportID} = Policy.createWorkspace(undefined, true, work);
Welcome.setOnboardingAdminsChatReportID(adminsChatReportID);
if (!onboardingPolicyID) {
const {adminsChatReportID, policyID} = Policy.createWorkspace(undefined, true, work);
Welcome.setOnboardingAdminsChatReportID(adminsChatReportID);
Welcome.setOnboardingPolicyID(policyID);
} else {
Policy.updateGeneralSettings(onboardingPolicyID, work);
}

Navigation.navigate(ROUTES.ONBOARDING_PERSONAL_DETAILS);
},
[onboardingPurposeSelected],
[onboardingPurposeSelected, onboardingPolicyID],
);

const validate = (values: FormOnyxValues<'onboardingWorkForm'>) => {
Expand Down Expand Up @@ -118,4 +124,7 @@ export default withOnyx<BaseOnboardingWorkProps, BaseOnboardingWorkOnyxProps>({
onboardingPurposeSelected: {
key: ONYXKEYS.ONBOARDING_PURPOSE_SELECTED,
},
onboardingPolicyID: {
key: ONYXKEYS.ONBOARDING_POLICY_ID,
},
})(BaseOnboardingWork);
3 changes: 3 additions & 0 deletions src/pages/OnboardingWork/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ type OnboardingWorkProps = Record<string, unknown>;
type BaseOnboardingWorkOnyxProps = {
/** Saved onboarding purpose selected by the user */
onboardingPurposeSelected: OnyxEntry<OnboardingPurposeType>;

/** Saved onboarding purpose selected by the user */
onboardingPolicyID: OnyxEntry<string>;
};

type BaseOnboardingWorkProps = BaseOnboardingWorkOnyxProps & {
Expand Down