From 7622e111a0ffe20029d7d5040ece29d206d545e8 Mon Sep 17 00:00:00 2001 From: Carlos Miceli Date: Thu, 3 Oct 2024 13:28:18 -0300 Subject: [PATCH] minor refactoring per suggestions --- src/CONST.ts | 3 ++- src/libs/Navigation/AppNavigator/AuthScreens.tsx | 7 +++---- src/libs/actions/Welcome/OnboardingFlow.ts | 2 +- src/pages/OnboardingWork/BaseOnboardingWork.tsx | 4 ++-- src/types/onyx/Onboarding.ts | 5 ++++- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 4a735e934ee9..e6539b72d5a1 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -88,7 +88,7 @@ const signupQualifiers = { INDIVIDUAL: 'individual', VSB: 'vsb', SMB: 'smb', -}; +} as const; const onboardingEmployerOrSubmitMessage: OnboardingMessageType = { message: 'Getting paid back is as easy as sending a message. Let’s go over the basics.', @@ -4469,6 +4469,7 @@ const CONST = { WELCOME_VIDEO_URL: `${CLOUDFRONT_URL}/videos/intro-1280.mp4`, + QUALIFIER_PARAM: 'signupQualifier', ONBOARDING_INTRODUCTION: 'Let’s get you set up 🔧', ONBOARDING_CHOICES: {...onboardingChoices}, SELECTABLE_ONBOARDING_CHOICES: {...selectableOnboardingChoices}, diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index ddbb11759eb0..f2f82176a54c 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.tsx +++ b/src/libs/Navigation/AppNavigator/AuthScreens.tsx @@ -275,10 +275,9 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie } let signupQualifier; - if (currentUrl.includes('signupQualifier')) { - signupQualifier = new URL(currentUrl).searchParams.get('signupQualifier'); - } - if (signupQualifier) { + if (currentUrl.includes(CONST.QUALIFIER_PARAM)) { + signupQualifier = new URL(currentUrl).searchParams.get(CONST.QUALIFIER_PARAM); + if (signupQualifier === CONST.ONBOARDING_SIGNUP_QUALIFIERS.INDIVIDUAL) { Welcome.setOnboardingCustomChoices([CONST.ONBOARDING_CHOICES.PERSONAL_SPEND, CONST.ONBOARDING_CHOICES.EMPLOYER, CONST.ONBOARDING_CHOICES.CHAT_SPLIT]); } diff --git a/src/libs/actions/Welcome/OnboardingFlow.ts b/src/libs/actions/Welcome/OnboardingFlow.ts index a96688d8c3ad..4ab3cda27c64 100644 --- a/src/libs/actions/Welcome/OnboardingFlow.ts +++ b/src/libs/actions/Welcome/OnboardingFlow.ts @@ -115,7 +115,7 @@ function startOnboardingFlow() { function getOnboardingInitialPath(): string { const state = getStateFromPath(onboardingInitialPath, linkingConfig.config); - const showBusinessModal = onboardingValues && 'signupQualifier' in onboardingValues && onboardingValues.signupQualifier === CONST.ONBOARDING_SIGNUP_QUALIFIERS.VSB; + const showBusinessModal = onboardingValues && CONST.QUALIFIER_PARAM in onboardingValues && onboardingValues.signupQualifier === CONST.ONBOARDING_SIGNUP_QUALIFIERS.VSB; if (showBusinessModal) { return `/${ROUTES.ONBOARDING_WORK.route}`; diff --git a/src/pages/OnboardingWork/BaseOnboardingWork.tsx b/src/pages/OnboardingWork/BaseOnboardingWork.tsx index 03dbada60f9c..9e8e2e3bbfa8 100644 --- a/src/pages/OnboardingWork/BaseOnboardingWork.tsx +++ b/src/pages/OnboardingWork/BaseOnboardingWork.tsx @@ -36,7 +36,7 @@ function BaseOnboardingWork({shouldUseNativeStyles, route}: BaseOnboardingWorkPr const {inputCallbackRef} = useAutoFocusInput(); const {isOffline} = useNetwork(); - const vsbOnboarding = onboardingValues && 'signupQualifier' in onboardingValues && onboardingValues.signupQualifier === CONST.ONBOARDING_SIGNUP_QUALIFIERS.VSB; + const isVsbOnboarding = onboardingValues && CONST.QUALIFIER_PARAM in onboardingValues && onboardingValues.signupQualifier === CONST.ONBOARDING_SIGNUP_QUALIFIERS.VSB; const completeEngagement = useCallback( (values: FormOnyxValues<'onboardingWorkForm'>) => { @@ -82,7 +82,7 @@ function BaseOnboardingWork({shouldUseNativeStyles, route}: BaseOnboardingWorkPr style={[styles.defaultModalContainer, shouldUseNativeStyles && styles.pt8]} > diff --git a/src/types/onyx/Onboarding.ts b/src/types/onyx/Onboarding.ts index 5bb022b6fd17..4b6a52f25cb4 100644 --- a/src/types/onyx/Onboarding.ts +++ b/src/types/onyx/Onboarding.ts @@ -1,3 +1,6 @@ +import type {ValueOf} from 'type-fest'; +import type CONST from '@src/CONST'; + /** Model of onboarding */ type Onboarding = { /** ID of the report used to display the onboarding checklist message */ @@ -7,7 +10,7 @@ type Onboarding = { hasCompletedGuidedSetupFlow: boolean; /** A string that informs which qualifier the user selected during sign up */ - signupQualifier: string; + signupQualifier: ValueOf; }; export default Onboarding;