Skip to content

Commit

Permalink
onboarding flow without errors
Browse files Browse the repository at this point in the history
  • Loading branch information
allroundexperts committed Nov 3, 2024
1 parent bef062b commit ad6007b
Show file tree
Hide file tree
Showing 34 changed files with 635 additions and 38 deletions.
3 changes: 3 additions & 0 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ const ONYXKEYS = {
/** Store the information of magic code */
VALIDATE_ACTION_CODE: 'validate_action_code',

KEY_JOINABLE_POLICIES: 'keyJoinablePolicies',

/** Information about the current session (authToken, accountID, email, loading, error) */
SESSION: 'session',
STASHED_SESSION: 'stashedSession',
Expand Down Expand Up @@ -907,6 +909,7 @@ type OnyxValuesMapping = {
[ONYXKEYS.LOGIN_LIST]: OnyxTypes.LoginList;
[ONYXKEYS.PENDING_CONTACT_ACTION]: OnyxTypes.PendingContactAction;
[ONYXKEYS.VALIDATE_ACTION_CODE]: OnyxTypes.ValidateMagicCodeAction;
[ONYXKEYS.KEY_JOINABLE_POLICIES]: OnyxTypes.JoinablePolicies;
[ONYXKEYS.SESSION]: OnyxTypes.Session;
[ONYXKEYS.USER_METADATA]: OnyxTypes.UserMetadata;
[ONYXKEYS.STASHED_SESSION]: OnyxTypes.Session;
Expand Down
8 changes: 8 additions & 0 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1325,6 +1325,10 @@ const ROUTES = {
route: 'onboarding/personal-details',
getRoute: (backTo?: string) => getUrlWithBackToParam(`onboarding/personal-details`, backTo),
},
ONBOARDING_PRIVATE_DOMAIN: {
route: 'onboarding/private-domain',
getRoute: (backTo?: string) => getUrlWithBackToParam(`onboarding/private-domain`, backTo),
},
ONBOARDING_EMPLOYEES: {
route: 'onboarding/employees',
getRoute: (backTo?: string) => getUrlWithBackToParam(`onboarding/employees`, backTo),
Expand All @@ -1337,6 +1341,10 @@ const ROUTES = {
route: 'onboarding/purpose',
getRoute: (backTo?: string) => getUrlWithBackToParam(`onboarding/purpose`, backTo),
},
ONBOARDING_WORKSPACES: {
route: 'onboarding/workspaces',
getRoute: (backTo?: string) => getUrlWithBackToParam(`onboarding/workspaces`, backTo),
},
WELCOME_VIDEO_ROOT: 'onboarding/welcome-video',
EXPLANATION_MODAL_ROOT: 'onboarding/explanation',

Expand Down
2 changes: 2 additions & 0 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,10 @@ const SCREENS = {
ONBOARDING: {
PERSONAL_DETAILS: 'Onboarding_Personal_Details',
PURPOSE: 'Onboarding_Purpose',
PRIVATE_DOMAIN: 'Onboarding_Private_Domain',
EMPLOYEES: 'Onboarding_Employees',
ACCOUNTING: 'Onboarding_Accounting',
WORKSPACES: 'Onboarding_Workspaces',
},

WELCOME_VIDEO: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ type ValidateCodeFormProps = {
/** Function to clear error of the form */
clearError: () => void;

/** Whether to show the verify button (hidden in private domain onboarding) */
hideButton?: boolean;

/** Function is called when validate code modal is mounted and on magic code resend */
sendValidateCode: () => void;
};
Expand All @@ -78,6 +81,7 @@ function BaseValidateCodeForm({
clearError,
sendValidateCode,
buttonStyles,
hideButton,
}: ValidateCodeFormProps) {
const {translate} = useLocalize();
const {isOffline} = useNetwork();
Expand Down Expand Up @@ -259,15 +263,17 @@ function BaseValidateCodeForm({
onClose={() => clearError()}
style={buttonStyles}
>
<Button
isDisabled={isOffline}
text={translate('common.verify')}
onPress={validateAndSubmitForm}
style={[styles.mt4]}
success
large
isLoading={account?.isLoading}
/>
{!hideButton && (
<Button
isDisabled={isOffline}
text={translate('common.verify')}
onPress={validateAndSubmitForm}
style={[styles.mt4]}
success
large
isLoading={account?.isLoading}
/>
)}
</OfflineWithFeedback>
</>
);
Expand Down
10 changes: 7 additions & 3 deletions src/hooks/useOnboardingFlow.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {useEffect} from 'react';
import {NativeModules} from 'react-native';
import {useOnyx} from 'react-native-onyx';
import * as LoginUtils from '@libs/LoginUtils';
import Navigation from '@libs/Navigation/Navigation';
import {hasCompletedGuidedSetupFlowSelector, hasCompletedHybridAppOnboardingFlowSelector} from '@libs/onboardingSelectors';
import * as OnboardingFlow from '@userActions/Welcome/OnboardingFlow';
Expand All @@ -21,6 +22,9 @@ function useOnboardingFlowRouter() {
selector: hasCompletedHybridAppOnboardingFlowSelector,
});

const [session] = useOnyx(ONYXKEYS.SESSION);
const isPrivateDomain = !!session?.email && !LoginUtils.isEmailPublicDomain(session?.email);

useEffect(() => {
if (isLoadingOnyxValue(isOnboardingCompletedMetadata, isHybridAppOnboardingCompletedMetadata)) {
return;
Expand All @@ -35,15 +39,15 @@ function useOnboardingFlowRouter() {
// But if the hybrid app onboarding is completed, but NewDot onboarding is not completed, we start NewDot onboarding flow
// This is a special case when user created an account from NewDot without finishing the onboarding flow and then logged in from OldDot
if (isHybridAppOnboardingCompleted === true && isOnboardingCompleted === false) {
OnboardingFlow.startOnboardingFlow();
OnboardingFlow.startOnboardingFlow(isPrivateDomain);
}
}

// If the user is not transitioning from OldDot to NewDot, we should start NewDot onboarding flow if it's not completed yet
if (!NativeModules.HybridAppModule && isOnboardingCompleted === false) {
OnboardingFlow.startOnboardingFlow();
OnboardingFlow.startOnboardingFlow(isPrivateDomain);
}
}, [isOnboardingCompleted, isHybridAppOnboardingCompleted, isOnboardingCompletedMetadata, isHybridAppOnboardingCompletedMetadata]);
}, [isOnboardingCompleted, isHybridAppOnboardingCompleted, isOnboardingCompletedMetadata, isHybridAppOnboardingCompletedMetadata, isPrivateDomain]);

return {isOnboardingCompleted, isHybridAppOnboardingCompleted};
}
Expand Down
10 changes: 10 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ import type {
WelcomeToRoomParams,
WeSentYouMagicSignInLinkParams,
WorkspaceOwnerWillNeedToAddOrUpdatePaymentCardParams,
WorkspaceYouMayJoin,
YourPlanPriceParams,
ZipCodeExampleFormatParams,
} from './params';
Expand Down Expand Up @@ -470,6 +471,7 @@ const translations = {
links: 'Links',
days: 'days',
rename: 'Rename',
skip: 'Skip',
},
location: {
useCurrent: 'Use current location',
Expand Down Expand Up @@ -1733,6 +1735,10 @@ const translations = {
},
getStarted: 'Get started',
whatsYourName: "What's your name?",
peopleYouMayKnow: 'People you may know are already here! Verify your email to join them.',
workspaceYouMayJoin: ({domain, email}: WorkspaceYouMayJoin) => `Someone from ${domain} has already created a workspace. Please enter the magic code sent to ${email}.`,
joinAWorkspace: 'Join a workspace',
listOfWorkspaces: "Here's the list of workspaces you can join. Don't worry, you can always join them later if you prefer.",
whereYouWork: 'Where do you work?',
errorSelection: 'Please make a selection to continue.',
purpose: {
Expand Down Expand Up @@ -2598,6 +2604,10 @@ const translations = {
noAccountsFound: 'No accounts found',
noAccountsFoundDescription: 'Add the account in Quickbooks Online and sync the connection again.',
},
workspaceList: {
joinNow: 'Join now',
askToJoin: 'Ask to join',
},
xero: {
organization: 'Xero organization',
organizationDescription: "Choose the Xero organization that you'd like to import data from.",
Expand Down
10 changes: 10 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ import type {
WelcomeToRoomParams,
WeSentYouMagicSignInLinkParams,
WorkspaceOwnerWillNeedToAddOrUpdatePaymentCardParams,
WorkspaceYouMayJoin,
YourPlanPriceParams,
ZipCodeExampleFormatParams,
} from './params';
Expand Down Expand Up @@ -341,6 +342,7 @@ const translations = {
semicolon: 'el punto y coma',
please: 'Por favor',
rename: 'Renombrar',
skip: 'Saltarse',
contactUs: 'contáctenos',
pleaseEnterEmailOrPhoneNumber: 'Por favor, escribe un email o número de teléfono',
fixTheErrors: 'corrige los errores',
Expand Down Expand Up @@ -1734,6 +1736,10 @@ const translations = {
},
getStarted: 'Comenzar',
whatsYourName: '¿Cómo te llamas?',
peopleYouMayKnow: 'Las personas que tal vez conozcas ya están aquí. Verifica tu correo electrónico para unirte a ellos.',
workspaceYouMayJoin: ({domain, email}: WorkspaceYouMayJoin) => `Alguien de ${domain} ya ha creado un espacio de trabajo. Por favor, introduce el código mágico enviado a ${email}.`,
joinAWorkspace: 'Unirse a un espacio de trabajo',
listOfWorkspaces: 'Aquí está la lista de espacios de trabajo a los que puedes unirte. No te preocupes, siempre puedes unirte a ellos más tarde si lo prefieres.',
whereYouWork: '¿Dónde trabajas?',
errorSelection: 'Por favor selecciona una opción para continuar.',
purpose: {
Expand Down Expand Up @@ -2628,6 +2634,10 @@ const translations = {
noAccountsFound: 'No se ha encontrado ninguna cuenta',
noAccountsFoundDescription: 'Añade la cuenta en Quickbooks Online y sincroniza de nuevo la conexión.',
},
workspaceList: {
joinNow: 'Únete ahora',
askToJoin: 'Pedir unirse',
},
xero: {
organization: 'Organización Xero',
organizationDescription: 'Seleccione la organización en Xero desde la que está importando los datos.',
Expand Down
6 changes: 6 additions & 0 deletions src/languages/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,11 @@ type ImportedTypesParams = {
importedTypes: string[];
};

type WorkspaceYouMayJoin = {
domain: string;
email: string;
};

type FileLimitParams = {
fileLimit: number;
};
Expand Down Expand Up @@ -746,4 +751,5 @@ export type {
OptionalParam,
AssignCardParams,
ImportedTypesParams,
WorkspaceYouMayJoin,
};
5 changes: 5 additions & 0 deletions src/libs/API/parameters/JoinAccessiblePolicyParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type JoinAccessiblePolicyParams = {
policyID: string;
};

export default JoinAccessiblePolicyParams;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type ValidateUserAndGetAccessiblePoliciesParams = {
validationCode: string;
};

export default ValidateUserAndGetAccessiblePoliciesParams;
2 changes: 2 additions & 0 deletions src/libs/API/parameters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,5 +345,7 @@ export type {default as ConnectPolicyToQuickBooksDesktopParams} from './ConnectP
export type {default as UpdateInvoiceCompanyNameParams} from './UpdateInvoiceCompanyNameParams';
export type {default as UpdateInvoiceCompanyWebsiteParams} from './UpdateInvoiceCompanyWebsiteParams';
export type {default as UpdateQuickbooksDesktopExpensesExportDestinationTypeParams} from './UpdateQuickbooksDesktopExpensesExportDestinationTypeParams';
export type {default as ValidateUserAndGetAccessiblePoliciesParams} from './ValidateUserAndGetAccessiblePoliciesParams';
export type {default as UpdateQuickbooksDesktopCompanyCardExpenseAccountTypeParams} from './UpdateQuickbooksDesktopCompanyCardExpenseAccountTypeParams';
export type {default as TogglePlatformMuteParams} from './TogglePlatformMuteParams';
export type {default as JoinAccessiblePolicyParams} from './JoinAccessiblePolicyParams';
5 changes: 5 additions & 0 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ const WRITE_COMMANDS = {
SET_POLICY_TAXES_FOREIGN_CURRENCY_DEFAULT: 'SetPolicyForeignCurrencyDefaultTax',
SET_POLICY_CUSTOM_TAX_NAME: 'SetPolicyCustomTaxName',
JOIN_POLICY_VIA_INVITE_LINK: 'JoinWorkspaceViaInviteLink',
JOIN_ACCESSIBLE_POLICY: 'JoinAccessiblePolicy',
ACCEPT_JOIN_REQUEST: 'AcceptJoinRequest',
DECLINE_JOIN_REQUEST: 'DeclineJoinRequest',
CREATE_POLICY_TAX: 'CreatePolicyTax',
Expand Down Expand Up @@ -436,6 +437,7 @@ const WRITE_COMMANDS = {
SET_INVOICING_TRANSFER_BANK_ACCOUNT: 'SetInvoicingTransferBankAccount',
UPDATE_INVOICE_COMPANY_NAME: 'UpdateInvoiceCompanyName',
UPDATE_INVOICE_COMPANY_WEBSITE: 'UpdateInvoiceCompanyWebsite',
VALIDATE_USER_AND_GET_ACCESSIBLE_POLICIES: 'ValidateUserAndGetAccessiblePolicies',
} as const;

type WriteCommand = ValueOf<typeof WRITE_COMMANDS>;
Expand Down Expand Up @@ -672,6 +674,7 @@ type WriteCommandParameters = {
[WRITE_COMMANDS.SEARCH]: Parameters.SearchParams;
[WRITE_COMMANDS.SET_POLICY_CATEGORY_TAX]: Parameters.SetPolicyCategoryTaxParams;
[WRITE_COMMANDS.JOIN_POLICY_VIA_INVITE_LINK]: Parameters.JoinPolicyInviteLinkParams;
[WRITE_COMMANDS.VALIDATE_USER_AND_GET_ACCESSIBLE_POLICIES]: Parameters.ValidateUserAndGetAccessiblePoliciesParams;
[WRITE_COMMANDS.ACCEPT_JOIN_REQUEST]: Parameters.AcceptJoinRequestParams;
[WRITE_COMMANDS.DECLINE_JOIN_REQUEST]: Parameters.DeclineJoinRequestParams;
[WRITE_COMMANDS.SET_POLICY_TAXES_CURRENCY_DEFAULT]: Parameters.SetPolicyCurrencyDefaultParams;
Expand Down Expand Up @@ -883,6 +886,8 @@ type WriteCommandParameters = {
[WRITE_COMMANDS.SET_INVOICING_TRANSFER_BANK_ACCOUNT]: Parameters.SetInvoicingTransferBankAccountParams;
[WRITE_COMMANDS.UPDATE_INVOICE_COMPANY_NAME]: Parameters.UpdateInvoiceCompanyNameParams;
[WRITE_COMMANDS.UPDATE_INVOICE_COMPANY_WEBSITE]: Parameters.UpdateInvoiceCompanyWebsiteParams;

[WRITE_COMMANDS.JOIN_ACCESSIBLE_POLICY]: Parameters.JoinAccessiblePolicyParams;
};

const READ_COMMANDS = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import OnboardingRefManager from '@libs/OnboardingRefManager';
import OnboardingAccounting from '@pages/OnboardingAccounting';
import OnboardingEmployees from '@pages/OnboardingEmployees';
import OnboardingPersonalDetails from '@pages/OnboardingPersonalDetails';
import OnboardingPrivateDomain from '@pages/OnboardingPrivateDomain';
import OnboardingPurpose from '@pages/OnboardingPurpose';
import OnboardingWorkspaces from '@pages/OnboardingWorkspaces';
import CONST from '@src/CONST';
import SCREENS from '@src/SCREENS';
import Overlay from './Overlay';
Expand Down Expand Up @@ -52,6 +54,14 @@ function OnboardingModalNavigator() {
name={SCREENS.ONBOARDING.PERSONAL_DETAILS}
component={OnboardingPersonalDetails}
/>
<Stack.Screen
name={SCREENS.ONBOARDING.PRIVATE_DOMAIN}
component={OnboardingPrivateDomain}
/>
<Stack.Screen
name={SCREENS.ONBOARDING.WORKSPACES}
component={OnboardingWorkspaces}
/>
<Stack.Screen
name={SCREENS.ONBOARDING.EMPLOYEES}
component={OnboardingEmployees}
Expand Down
5 changes: 4 additions & 1 deletion src/libs/Navigation/NavigationRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import useTheme from '@hooks/useTheme';
import Firebase from '@libs/Firebase';
import {FSPage} from '@libs/Fullstory';
import Log from '@libs/Log';
import * as LoginUtils from '@libs/LoginUtils';
import {hasCompletedGuidedSetupFlowSelector} from '@libs/onboardingSelectors';
import {getPathFromURL} from '@libs/Url';
import {updateLastVisitedPath} from '@userActions/App';
Expand Down Expand Up @@ -90,6 +91,8 @@ function NavigationRoot({authenticated, lastVisitedPath, initialUrl, onReady, sh
const {shouldUseNarrowLayout} = useResponsiveLayout();
const {setActiveWorkspaceID} = useActiveWorkspace();
const [user] = useOnyx(ONYXKEYS.USER);
const [session] = useOnyx(ONYXKEYS.SESSION);
const isPrivateDomain = !!session?.email && !LoginUtils.isEmailPublicDomain(session?.email);

const [isOnboardingCompleted = true] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {
selector: hasCompletedGuidedSetupFlowSelector,
Expand All @@ -103,7 +106,7 @@ function NavigationRoot({authenticated, lastVisitedPath, initialUrl, onReady, sh
// If the user haven't completed the flow, we want to always redirect them to the onboarding flow.
// We also make sure that the user is authenticated.
if (!NativeModules.HybridAppModule && !isOnboardingCompleted && authenticated && !shouldShowRequire2FAModal) {
const {adaptedState} = getAdaptedStateFromPath(getOnboardingInitialPath(), linkingConfig.config);
const {adaptedState} = getAdaptedStateFromPath(getOnboardingInitialPath(isPrivateDomain), linkingConfig.config);
return adaptedState;
}

Expand Down
8 changes: 8 additions & 0 deletions src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ const config: LinkingOptions<RootStackParamList>['config'] = {
path: ROUTES.ONBOARDING_PERSONAL_DETAILS.route,
exact: true,
},
[SCREENS.ONBOARDING.PRIVATE_DOMAIN]: {
path: ROUTES.ONBOARDING_PRIVATE_DOMAIN.route,
exact: true,
},
[SCREENS.ONBOARDING.EMPLOYEES]: {
path: ROUTES.ONBOARDING_EMPLOYEES.route,
exact: true,
Expand All @@ -126,6 +130,10 @@ const config: LinkingOptions<RootStackParamList>['config'] = {
path: ROUTES.ONBOARDING_ACCOUNTING.route,
exact: true,
},
[SCREENS.ONBOARDING.WORKSPACES]: {
path: ROUTES.ONBOARDING_WORKSPACES.route,
exact: true,
},
},
},
[NAVIGATORS.RIGHT_MODAL_NAVIGATOR]: {
Expand Down
6 changes: 6 additions & 0 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1482,6 +1482,12 @@ type OnboardingModalNavigatorParamList = {
[SCREENS.ONBOARDING.PERSONAL_DETAILS]: {
backTo?: string;
};
[SCREENS.ONBOARDING.PRIVATE_DOMAIN]: {
backTo?: string;
};
[SCREENS.ONBOARDING.WORKSPACES]: {
backTo?: string;
};
[SCREENS.ONBOARDING.PURPOSE]: {
backTo?: string;
};
Expand Down
2 changes: 2 additions & 0 deletions src/libs/NavigationUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const ONBOARDING_SCREEN_NAMES = new Set([
SCREENS.ONBOARDING_MODAL.ONBOARDING,
SCREENS.ONBOARDING.EMPLOYEES,
SCREENS.ONBOARDING.ACCOUNTING,
SCREENS.ONBOARDING.PRIVATE_DOMAIN,
SCREENS.ONBOARDING.WORKSPACES,
]);

const removePolicyIDParamFromState = (state: State<RootStackParamList>) => {
Expand Down
Loading

0 comments on commit ad6007b

Please sign in to comment.