Skip to content
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

Adjust the Guided Setup Flow based on user's Sign Up Qualifier #47619

Merged
merged 33 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a458840
grabbing signupqualifer param
carlosmiceli Aug 19, 2024
adffd52
Merge branch 'main' into cm-guided-setup-flow
carlosmiceli Aug 19, 2024
108229b
adding new onyx key
carlosmiceli Aug 19, 2024
1f70dec
setting new onboarding choices/purpose nvp
carlosmiceli Aug 19, 2024
34c67a2
set nvp values with actions
carlosmiceli Aug 19, 2024
e13c625
fix prettier
carlosmiceli Aug 19, 2024
b4510f1
Merge branch 'main' into cm-guided-setup-flow
carlosmiceli Aug 20, 2024
e1eaefb
fix missing signupQualifier case
carlosmiceli Aug 20, 2024
d639cbe
fix lint
carlosmiceli Aug 20, 2024
ffc3d00
merge main, resolving conflicts
carlosmiceli Sep 25, 2024
c17d7c1
add setOnboardingCustomChoices
carlosmiceli Sep 25, 2024
80536b4
filter onboarding choices based for individual signups
carlosmiceli Sep 26, 2024
8b9d014
fix lint
carlosmiceli Sep 26, 2024
706a735
improving constants and types
carlosmiceli Sep 27, 2024
444208c
cleanup constants
carlosmiceli Sep 27, 2024
cd773f1
use constants and set custom choices
carlosmiceli Sep 27, 2024
0db9204
remove back button from onboarding work
carlosmiceli Sep 27, 2024
3051ffa
prettier
carlosmiceli Sep 27, 2024
b61e243
cleanup withOnyx
carlosmiceli Sep 27, 2024
600fe90
Merge branch 'main' into cm-guided-setup-flow
carlosmiceli Sep 27, 2024
4a79b6a
add route to onboarding work
carlosmiceli Sep 27, 2024
24cccd9
suggestions
carlosmiceli Sep 30, 2024
99a50d2
fix prettier
carlosmiceli Sep 30, 2024
1eeab2b
fix prettier
carlosmiceli Sep 30, 2024
9dbc6d7
Merge branch 'main' of github.com:Expensify/App into cm-guided-setup-…
carlosmiceli Sep 30, 2024
adb2cde
refactor code
carlosmiceli Sep 30, 2024
e8b7582
fix prettier again
carlosmiceli Sep 30, 2024
36b4cbf
code cleanup
carlosmiceli Oct 3, 2024
1da543a
fix double submit routing issue
carlosmiceli Oct 3, 2024
783f518
fix prettier
carlosmiceli Oct 3, 2024
ca04353
eslint
carlosmiceli Oct 3, 2024
f0c2b2a
Update src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx
carlosmiceli Oct 3, 2024
7622e11
minor refactoring per suggestions
carlosmiceli Oct 3, 2024
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
8 changes: 8 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ const onboardingChoices = {
...backendOnboardingChoices,
} as const;

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.',
video: {
Expand Down Expand Up @@ -4463,9 +4469,11 @@ 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},
ONBOARDING_SIGNUP_QUALIFIERS: {...signupQualifiers},
ONBOARDING_INVITE_TYPES: {...onboardingInviteTypes},
ACTIONABLE_TRACK_EXPENSE_WHISPER_MESSAGE: 'What would you like to do with this expense?',
ONBOARDING_CONCIERGE: {
Expand Down
4 changes: 4 additions & 0 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,9 @@ const ONYXKEYS = {
/** Onboarding Purpose selected by the user during Onboarding flow */
ONBOARDING_PURPOSE_SELECTED: 'onboardingPurposeSelected',

/** Onboarding customized choices to display to the user based on their profile when signing up */
ONBOARDING_CUSTOM_CHOICES: 'onboardingCustomChoices',

/** Onboarding error message to be displayed to the user */
ONBOARDING_ERROR_MESSAGE: 'onboardingErrorMessage',

Expand Down Expand Up @@ -950,6 +953,7 @@ type OnyxValuesMapping = {
[ONYXKEYS.MAX_CANVAS_HEIGHT]: number;
[ONYXKEYS.MAX_CANVAS_WIDTH]: number;
[ONYXKEYS.ONBOARDING_PURPOSE_SELECTED]: OnboardingPurposeType;
[ONYXKEYS.ONBOARDING_CUSTOM_CHOICES]: OnboardingPurposeType[] | [];
[ONYXKEYS.ONBOARDING_ERROR_MESSAGE]: string;
[ONYXKEYS.ONBOARDING_POLICY_ID]: string;
[ONYXKEYS.ONBOARDING_ADMINS_CHAT_REPORT_ID]: string;
Expand Down
13 changes: 13 additions & 0 deletions src/libs/Navigation/AppNavigator/AuthScreens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import usePermissions from '@hooks/usePermissions';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useStyleUtils from '@hooks/useStyleUtils';
import useThemeStyles from '@hooks/useThemeStyles';
import * as Welcome from '@libs/actions/Welcome';
import {READ_COMMANDS} from '@libs/API/types';
import HttpUtils from '@libs/HttpUtils';
import KeyboardShortcut from '@libs/KeyboardShortcut';
Expand Down Expand Up @@ -273,6 +274,18 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie
return;
}

let signupQualifier;
carlosmiceli marked this conversation as resolved.
Show resolved Hide resolved
if (currentUrl.includes(CONST.QUALIFIER_PARAM)) {
signupQualifier = new URL(currentUrl).searchParams.get(CONST.QUALIFIER_PARAM);
carlosmiceli marked this conversation as resolved.
Show resolved Hide resolved

if (signupQualifier === CONST.ONBOARDING_SIGNUP_QUALIFIERS.INDIVIDUAL) {
Welcome.setOnboardingCustomChoices([CONST.ONBOARDING_CHOICES.PERSONAL_SPEND, CONST.ONBOARDING_CHOICES.EMPLOYER, CONST.ONBOARDING_CHOICES.CHAT_SPLIT]);
}
if (signupQualifier === CONST.ONBOARDING_SIGNUP_QUALIFIERS.VSB) {
Welcome.setOnboardingPurposeSelected(CONST.ONBOARDING_CHOICES.MANAGE_TEAM);
}
}

NetworkConnection.listenForReconnect();
NetworkConnection.onReconnect(handleNetworkReconnect);
PusherConnectionManager.init();
Expand Down
17 changes: 17 additions & 0 deletions src/libs/actions/Welcome/OnboardingFlow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import NAVIGATORS from '@src/NAVIGATORS';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import SCREENS from '@src/SCREENS';
import type Onboarding from '@src/types/onyx/Onboarding';

let selectedPurpose: string | undefined = '';
Onyx.connect({
Expand All @@ -31,6 +32,17 @@ const onboardingLastVisitedPathConnection = Onyx.connect({
},
});

let onboardingValues: Onboarding;
Onyx.connect({
key: ONYXKEYS.NVP_ONBOARDING,
callback: (value) => {
if (value === undefined) {
return;
}
carlosmiceli marked this conversation as resolved.
Show resolved Hide resolved
onboardingValues = value as Onboarding;
},
});

/**
* Build the correct stack order for `onboardingModalNavigator`,
* based on onboarding data (currently from the selected purpose).
Expand Down Expand Up @@ -103,6 +115,11 @@ function startOnboardingFlow() {

function getOnboardingInitialPath(): string {
const state = getStateFromPath(onboardingInitialPath, linkingConfig.config);
const showBusinessModal = onboardingValues && CONST.QUALIFIER_PARAM in onboardingValues && onboardingValues.signupQualifier === CONST.ONBOARDING_SIGNUP_QUALIFIERS.VSB;

if (showBusinessModal) {
return `/${ROUTES.ONBOARDING_WORK.route}`;
}
if (state?.routes?.at(-1)?.name !== NAVIGATORS.ONBOARDING_MODAL_NAVIGATOR) {
return `/${ROUTES.ONBOARDING_ROOT.route}`;
}
Expand Down
5 changes: 5 additions & 0 deletions src/libs/actions/Welcome/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ function checkOnboardingDataReady() {
resolveOnboardingFlowStatus();
}

function setOnboardingCustomChoices(value: OnboardingPurposeType[]) {
Onyx.set(ONYXKEYS.ONBOARDING_CUSTOM_CHOICES, value ?? []);
}

function setOnboardingPurposeSelected(value: OnboardingPurposeType) {
Onyx.set(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED, value ?? null);
}
Expand Down Expand Up @@ -178,6 +182,7 @@ function resetAllChecks() {
export {
onServerDataReady,
isOnboardingFlowCompleted,
setOnboardingCustomChoices,
setOnboardingPurposeSelected,
updateOnboardingLastVisitedPath,
resetAllChecks,
Expand Down
7 changes: 6 additions & 1 deletion src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ function BaseOnboardingPurpose({shouldUseNativeStyles, shouldEnableMaxHeight, ro
const maxHeight = shouldEnableMaxHeight ? windowHeight : undefined;
const paddingHorizontal = onboardingIsMediumOrLargerScreenWidth ? styles.ph8 : styles.ph5;

const menuItems: MenuItemProps[] = Object.values(CONST.SELECTABLE_ONBOARDING_CHOICES).map((choice) => {
const [customChoices = []] = useOnyx(ONYXKEYS.ONBOARDING_CUSTOM_CHOICES);

const onboardingChoices =
customChoices.length > 0 ? Object.values(CONST.SELECTABLE_ONBOARDING_CHOICES).filter((choice) => customChoices.includes(choice)) : Object.values(CONST.SELECTABLE_ONBOARDING_CHOICES);

const menuItems: MenuItemProps[] = onboardingChoices.map((choice) => {
const translationKey = `onboarding.purpose.${choice}` as const;
return {
key: translationKey,
Expand Down
5 changes: 4 additions & 1 deletion src/pages/OnboardingWork/BaseOnboardingWork.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ function BaseOnboardingWork({shouldUseNativeStyles, route}: BaseOnboardingWorkPr
const {translate} = useLocalize();
const [onboardingPurposeSelected] = useOnyx(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED);
const [onboardingPolicyID] = useOnyx(ONYXKEYS.ONBOARDING_POLICY_ID);
const [onboardingValues] = useOnyx(ONYXKEYS.NVP_ONBOARDING);
const {isSmallScreenWidth, onboardingIsMediumOrLargerScreenWidth} = useResponsiveLayout();
const {inputCallbackRef} = useAutoFocusInput();
const {isOffline} = useNetwork();

const isVsbOnboarding = onboardingValues && CONST.QUALIFIER_PARAM in onboardingValues && onboardingValues.signupQualifier === CONST.ONBOARDING_SIGNUP_QUALIFIERS.VSB;

const completeEngagement = useCallback(
(values: FormOnyxValues<'onboardingWorkForm'>) => {
if (!onboardingPurposeSelected) {
Expand Down Expand Up @@ -79,7 +82,7 @@ function BaseOnboardingWork({shouldUseNativeStyles, route}: BaseOnboardingWorkPr
style={[styles.defaultModalContainer, shouldUseNativeStyles && styles.pt8]}
>
<HeaderWithBackButton
shouldShowBackButton
shouldShowBackButton={!isVsbOnboarding}
progressBarPercentage={onboardingPurposeSelected === CONST.ONBOARDING_CHOICES.MANAGE_TEAM ? 50 : 75}
onBackButtonPress={OnboardingFlow.goBack}
/>
Expand Down
6 changes: 6 additions & 0 deletions src/types/onyx/Onboarding.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
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 */
chatReportID?: string;

/** A Boolean that informs whether the user has completed the guided setup onboarding flow */
hasCompletedGuidedSetupFlow: boolean;

/** A string that informs which qualifier the user selected during sign up */
signupQualifier: ValueOf<typeof CONST.ONBOARDING_SIGNUP_QUALIFIERS>;
};

export default Onboarding;
Loading