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

feat: add employee and accounting page to onboarding flow #49161

Merged
merged 61 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
accc8a1
feat: add employee and accounting page to onboarding flow
nkdengineer Sep 13, 2024
419f7cc
fix ts error
nkdengineer Sep 13, 2024
88dda39
Merge branch 'main' into fix/48745
nkdengineer Sep 16, 2024
6bdf7ed
add OnboadingListItem
nkdengineer Sep 16, 2024
e0bc748
fix test
nkdengineer Sep 16, 2024
de74800
add offline indicator and fix ts bug
nkdengineer Sep 16, 2024
5f75726
Merge branch 'main' into fix/48745
nkdengineer Sep 17, 2024
a37009d
fix the font-size issue
nkdengineer Sep 17, 2024
d72dec2
decrease spacing between title and description
nkdengineer Sep 17, 2024
2200305
Merge branch 'main' into fix/48745
nkdengineer Sep 18, 2024
646fc6d
Update src/pages/OnboardingEmployees/index.tsx
nkdengineer Sep 18, 2024
b7b016f
Update src/pages/OnboardingAccounting/index.tsx
nkdengineer Sep 18, 2024
6964f34
call completeOnboarding API
nkdengineer Sep 18, 2024
def4389
fix ts error
nkdengineer Sep 18, 2024
b923dab
Merge branch 'main' into fix/48745
nkdengineer Sep 18, 2024
b1e8c24
move the type to CONST
nkdengineer Sep 18, 2024
f8ff1f5
remove OnboardingListItem
nkdengineer Sep 18, 2024
a773766
remove onboardingIcon type
nkdengineer Sep 18, 2024
a50ce47
remove unused style
nkdengineer Sep 18, 2024
c9b6a0b
fix lint
nkdengineer Sep 18, 2024
0d6adac
merge main
nkdengineer Sep 19, 2024
13f4da9
add type and refactor style
nkdengineer Sep 19, 2024
944b3d3
Merge branch 'main' into fix/48745
nkdengineer Sep 20, 2024
1a67914
change firstname and lastname as optional
nkdengineer Sep 20, 2024
497a35e
migrate to useOnyx
nkdengineer Sep 20, 2024
ced0874
remove withOnyx
nkdengineer Sep 20, 2024
41de3e1
Merge branch 'main' into fix/48745
nkdengineer Sep 20, 2024
d417b6a
remove unnecessary code
nkdengineer Sep 20, 2024
c6c8cbc
Update src/SCREENS.ts
nkdengineer Sep 20, 2024
11f3a4a
Merge branch 'main' into fix/48745
nkdengineer Sep 23, 2024
465ffbc
Update src/CONST.ts
nkdengineer Sep 23, 2024
d3121d6
Update src/pages/OnboardingAccounting/BaseOnboardingAccounting.tsx
nkdengineer Sep 23, 2024
f72f134
refactor code
nkdengineer Sep 23, 2024
076d4af
Merge branch 'fix/48745' of https://github.com/nkdengineer/App into f…
nkdengineer Sep 23, 2024
ccfa4e1
fix type error
nkdengineer Sep 23, 2024
a1201d2
remove unnecessary prop
nkdengineer Sep 23, 2024
91bbbaf
Merge branch 'main' into fix/48745
nkdengineer Sep 24, 2024
63a5932
remove unused style
nkdengineer Sep 24, 2024
34f74ad
fix lint
nkdengineer Sep 24, 2024
fb70a3f
add style prop for list item
nkdengineer Sep 24, 2024
bdf3a08
Merge branch 'main' into fix/48745
nkdengineer Sep 25, 2024
d0be895
remove unnecessary prop
nkdengineer Sep 25, 2024
5e61daf
add pl8 and pr8 style
nkdengineer Sep 25, 2024
d8b71b0
Merge branch 'main' into fix/48745
nkdengineer Sep 27, 2024
0057cb1
resolve conflict
nkdengineer Oct 2, 2024
939c169
merge main
nkdengineer Oct 2, 2024
97e41e8
fix ts error
nkdengineer Oct 2, 2024
556b83f
merge main
nkdengineer Oct 8, 2024
fe9d9b5
remove description translation
nkdengineer Oct 8, 2024
9a1c414
Merge branch 'main' into fix/48745
nkdengineer Oct 8, 2024
8706f60
update translation
nkdengineer Oct 8, 2024
74631ed
Merge branch 'main' into fix/48745
nkdengineer Oct 8, 2024
4516b4d
update confirm button to continue button
nkdengineer Oct 8, 2024
aab3ad8
fix ts error
nkdengineer Oct 8, 2024
9985e88
remove unused variable
nkdengineer Oct 8, 2024
7bba26c
Merge branch 'main' into fix/48745
nkdengineer Oct 9, 2024
7fb12f0
remove onboaring work
nkdengineer Oct 9, 2024
433261c
merge main
nkdengineer Oct 9, 2024
f806fde
remove import type
nkdengineer Oct 9, 2024
3584504
merge main
nkdengineer Oct 10, 2024
bd6b524
merge main
nkdengineer Oct 10, 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
10 changes: 5 additions & 5 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ const onboardingInviteTypes = {
} as const;

const onboardingCompanySize = {
MICRO: 'micro',
SMALL: 'small',
MEDIUM_SMALL: 'mediumSmall',
MEDIUM: 'medium',
LARGE: 'large',
MICRO: '1-10',
SMALL: '11-50',
MEDIUM_SMALL: '51-100',
MEDIUM: '101-1000',
LARGE: '1001+',
};
nkdengineer marked this conversation as resolved.
Show resolved Hide resolved

type OnboardingInviteType = ValueOf<typeof onboardingInviteTypes>;
Expand Down
6 changes: 5 additions & 1 deletion src/libs/API/parameters/CompleteGuidedSetupParams.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import type {OnboardingPurposeType} from '@src/CONST';
import type {ValueOf} from 'type-fest';
import type CONST from '@src/CONST';
import type {OnboardingCompanySizeType, OnboardingPurposeType} from '@src/CONST';

type CompleteGuidedSetupParams = {
firstName: string;
Expand All @@ -7,6 +9,8 @@ type CompleteGuidedSetupParams = {
guidedSetupData: string;
engagementChoice: OnboardingPurposeType;
paymentSelected?: string;
companySize?: OnboardingCompanySizeType;
userReportedIntegration?: ValueOf<typeof CONST.POLICY.CONNECTIONS.NAME>;
};

export default CompleteGuidedSetupParams;
6 changes: 5 additions & 1 deletion src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
import shouldSkipDeepLinkNavigation from '@libs/shouldSkipDeepLinkNavigation';
import Visibility from '@libs/Visibility';
import CONFIG from '@src/CONFIG';
import type {OnboardingPurposeType} from '@src/CONST';
import type {OnboardingCompanySizeType, OnboardingPurposeType} from '@src/CONST';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Route} from '@src/ROUTES';
Expand Down Expand Up @@ -3341,6 +3341,8 @@
adminsChatReportID?: string,
onboardingPolicyID?: string,
paymentSelected?: string,
companySize?: OnboardingCompanySizeType,
userReportedIntegration?: ValueOf<typeof CONST.POLICY.CONNECTIONS.NAME> | null,
) {
const actorAccountID = CONST.ACCOUNT_ID.CONCIERGE;
const targetChatReport = ReportUtils.getChatByParticipants([actorAccountID, currentUserAccountID]);
Expand Down Expand Up @@ -3687,6 +3689,8 @@
actorAccountID,
guidedSetupData: JSON.stringify(guidedSetupData),
paymentSelected,
companySize,
userReportedIntegration,

Check failure on line 3693 in src/libs/actions/Report.ts

View workflow job for this annotation

GitHub Actions / typecheck

Type 'ValueOf<{ readonly QBO: "quickbooksOnline"; readonly XERO: "xero"; readonly NETSUITE: "netsuite"; readonly SAGE_INTACCT: "intacct"; }> | null | undefined' is not assignable to type 'ValueOf<{ readonly QBO: "quickbooksOnline"; readonly XERO: "xero"; readonly NETSUITE: "netsuite"; readonly SAGE_INTACCT: "intacct"; }> | undefined'.
};

API.write(WRITE_COMMANDS.COMPLETE_GUIDED_SETUP, parameters, {optimisticData, successData, failureData});
Expand Down
6 changes: 1 addition & 5 deletions src/libs/actions/Welcome/OnboardingFlow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,14 @@ function adaptOnboardingRouteState() {
}

let adaptedOnboardingModalNavigatorState = {} as Readonly<PartialState<NavigationState>>;
if (currentRoute?.name === SCREENS.ONBOARDING.PERSONAL_DETAILS && selectedPurpose === CONST.ONBOARDING_CHOICES.MANAGE_TEAM) {
if (currentRoute?.name === SCREENS.ONBOARDING.ACCOUNTING && selectedPurpose === CONST.ONBOARDING_CHOICES.MANAGE_TEAM) {
adaptedOnboardingModalNavigatorState = {
index: 2,
routes: [
{
name: SCREENS.ONBOARDING.PURPOSE,
params: currentRoute?.params,
},
{
name: SCREENS.ONBOARDING.WORK,
params: currentRoute?.params,
},
{
name: SCREENS.ONBOARDING.EMPLOYEES,
params: currentRoute?.params,
Expand Down
56 changes: 51 additions & 5 deletions src/pages/OnboardingAccounting/BaseOnboardingAccounting.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React, {useMemo, useState} from 'react';
import {View} from 'react-native';
import {useOnyx} from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
import Button from '@components/Button';
import FormHelpMessage from '@components/FormHelpMessage';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
Expand All @@ -15,23 +17,35 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import * as Policy from '@userActions/Policy/Policy';
import * as Report from '@userActions/Report';
import * as Welcome from '@userActions/Welcome';
import * as OnboardingFlow from '@userActions/Welcome/OnboardingFlow';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {} from '@src/types/onyx/Bank';
import type {OnboardingIcon} from '@src/types/onyx/Onboarding';
import type {BaseOnboardingAccountingProps} from './types';

type OnboardingAccountingType = ValueOf<typeof CONST.POLICY.CONNECTIONS.NAME>;
nkdengineer marked this conversation as resolved.
Show resolved Hide resolved

type OnboardingListItemData = ListItem & {
keyForList: OnboardingAccountingType | null;
onboardingIcon: OnboardingIcon;
};

function BaseOnboardingAccounting({shouldUseNativeStyles}: BaseOnboardingAccountingProps) {
function BaseOnboardingAccounting({shouldUseNativeStyles, route}: BaseOnboardingAccountingProps) {
const styles = useThemeStyles();
const theme = useTheme();
const StyleUtils = useStyleUtils();
const {translate} = useLocalize();
const {onboardingIsMediumOrLargerScreenWidth, shouldUseNarrowLayout} = useResponsiveLayout();
const [userReportedIntegration, setUserReportedIntegration] = useState<string | null | undefined>(undefined);
const [onboardingPurposeSelected] = useOnyx(ONYXKEYS.ONBOARDING_PURPOSE_SELECTED);
const [onboardingPolicyID] = useOnyx(ONYXKEYS.ONBOARDING_POLICY_ID);
const [onboardingAdminsChatReportID] = useOnyx(ONYXKEYS.ONBOARDING_ADMINS_CHAT_REPORT_ID);
const [onboardingCompanySize] = useOnyx(ONYXKEYS.ONBOARDING_COMPANY_SIZE);

const [userReportedIntegration, setUserReportedIntegration] = useState<OnboardingAccountingType | null | undefined>(undefined);
const [error, setError] = useState('');

const accountingOptions: OnboardingListItemData[] = useMemo(() => {
Expand Down Expand Up @@ -112,13 +126,44 @@ function BaseOnboardingAccounting({shouldUseNativeStyles}: BaseOnboardingAccount
text={translate('common.confirm')}
// eslint-disable-next-line rulesdir/prefer-early-return
nkdengineer marked this conversation as resolved.
Show resolved Hide resolved
nkdengineer marked this conversation as resolved.
Show resolved Hide resolved
onPress={() => {
if (!userReportedIntegration) {
if (userReportedIntegration === undefined) {
setError(translate('onboarding.purpose.errorSelection'));
nkdengineer marked this conversation as resolved.
Show resolved Hide resolved
// eslint-disable-next-line no-useless-return
nkdengineer marked this conversation as resolved.
Show resolved Hide resolved
return;
}

// TODO: call CompleOnboarding API after the back-end PR is complete
if (!onboardingPurposeSelected) {
return;
}
nkdengineer marked this conversation as resolved.
Show resolved Hide resolved

if (onboardingPolicyID) {
Policy.enablePolicyConnections(onboardingPolicyID, true);
}
nkdengineer marked this conversation as resolved.
Show resolved Hide resolved

Report.completeOnboarding(
onboardingPurposeSelected,
CONST.ONBOARDING_MESSAGES[onboardingPurposeSelected],
{
firstName: '',
lastName: '',
},
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be optional.

(To recheck: the BE seems to complain about the empty names)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we also update the default value of this data in compleOnboarding function with the default value as empty string?

Copy link
Contributor

Choose a reason for hiding this comment

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

Make it optional in completeOnboarding

Copy link
Contributor

Choose a reason for hiding this comment

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

AFAICT it is optional. Lmk what you are seeing. Yes I would update this to be optional.

I am also pretty confused about why it's being passed as an object if we can fix that while we are here. Maybe someone thought it better to parameterize the arguments? But the next person disagreed 😄

Looks inconsistent to me. Let's make it:

function completeOnboarding(
    engagementChoice: OnboardingPurposeType,
    data: ValueOf<typeof CONST.ONBOARDING_MESSAGES>,
    firstName?: string;
    lastName?: string;
    adminsChatReportID?: string,
    onboardingPolicyID?: string,
    paymentSelected?: string,
    ...
) {

Copy link
Contributor

Choose a reason for hiding this comment

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

@marcaaron

{
    "jsonCode": 402,
    "message": "402 Missing firstName",
    "onyxData": [],
    "requestID": "8c542209db944e20-ORN"
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Sigh... lol 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@marcaaron Should we add default value for firstName and lastName in completeOnboarding because in the type CompleteGuidedSetupParams, firstName and lastName is string.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes let's do it. We will need it in some cases, but not for the "manage team expense" choice so it is appropriate to make optional.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated.

onboardingAdminsChatReportID ?? undefined,
onboardingPolicyID,
undefined,
onboardingCompanySize,
userReportedIntegration,
);

Welcome.setOnboardingAdminsChatReportID();
Welcome.setOnboardingPolicyID();

Navigation.dismissModal();

// Only navigate to concierge chat when central pane is visible
// Otherwise stay on the chats screen.
if (!shouldUseNarrowLayout && !route.params?.backTo) {
Report.navigateToConciergeChat();
}
}}
pressOnEnter
/>
Expand Down Expand Up @@ -150,6 +195,7 @@ function BaseOnboardingAccounting({shouldUseNativeStyles}: BaseOnboardingAccount
sections={[{data: accountingOptions}]}
onSelectRow={(item) => {
setUserReportedIntegration(item.keyForList);
setError('');
}}
shouldUpdateFocusedIndex
ListItem={OnboardingListItem}
Expand Down
7 changes: 7 additions & 0 deletions src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import Navigation from '@libs/Navigation/Navigation';
import OnboardingRefManager from '@libs/OnboardingRefManager';
import type {TOnboardingRef} from '@libs/OnboardingRefManager';
import variables from '@styles/variables';
import * as Policy from '@userActions/Policy/Policy';
import * as Welcome from '@userActions/Welcome';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
Expand All @@ -38,6 +39,7 @@ const menuIcons = {
function BaseOnboardingPurpose({shouldUseNativeStyles, shouldEnableMaxHeight, route}: BaseOnboardingPurposeProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const [onboardingPolicyID] = useOnyx(ONYXKEYS.ONBOARDING_POLICY_ID);
const {onboardingIsMediumOrLargerScreenWidth} = useResponsiveLayout();
const {windowHeight} = useWindowDimensions();
// We need to use isSmallScreenWidth instead of shouldUseNarrowLayout to show offline indicator on small screen only
Expand Down Expand Up @@ -66,6 +68,11 @@ function BaseOnboardingPurpose({shouldUseNativeStyles, shouldEnableMaxHeight, ro
Welcome.setOnboardingErrorMessage('');

if (choice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM) {
if (!onboardingPolicyID) {
const {adminsChatReportID, policyID} = Policy.createWorkspace(undefined, true);
Welcome.setOnboardingAdminsChatReportID(adminsChatReportID);
Welcome.setOnboardingPolicyID(policyID);
}
Comment on lines +86 to +90
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we are not going to use the policy in between steps is there any reason that we create the workspace at that early step? Why not create it just before calling completeOnboarding in the accounting step?

Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting. Did you have any concern about that or opinion on why it would be better to do one over the other?

Copy link
Contributor

Choose a reason for hiding this comment

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

No strong preference it's just a little questionable that we create the workspace when not really needed yet. Now I think about it more I think we may have a bug:

  1. Login as a new user
  2. On the onboarding flow, select purpose to manage team <-- This will create a workspace
  3. Logout
  4. Login in again
  5. If you try to complete the onboarding flow you will be creating another workspace since onboardingPolicyID is not on onyx

cc @nkdengineer Can you please confirm if you can reproduce this bug?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh hmm that's an interesting edge case for sure - I'm not sure how we would completely solve that without designating a specific policy as the "onboarding policy". Though we could potentially check if a user has an existing policy.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixing the problem highlighted in #50759 may fix this as I think we will have to send the policy id from the backend

Navigation.navigate(ROUTES.ONBOARDING_EMPLOYEES.getRoute(route.params?.backTo));
return;
}
Expand Down
Loading