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
21 changes: 21 additions & 0 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ import * as ErrorUtils from '@libs/ErrorUtils';
import {getMicroSecondOnyxErrorWithTranslationKey} from '@libs/ErrorUtils';
import fileDownload from '@libs/fileDownload';
import getIsNarrowLayout from '@libs/getIsNarrowLayout';
import getPlatform from '@libs/getPlatform';
import HttpUtils from '@libs/HttpUtils';
import isPublicScreenRoute from '@libs/isPublicScreenRoute';
import * as Localize from '@libs/Localize';
Expand Down Expand Up @@ -3982,6 +3983,26 @@ function completeOnboarding({
selfDMCreatedReportActionID: selfDMParameters.createdReportActionID,
};

if (companySize && companySize !== CONST.ONBOARDING_COMPANY_SIZE.MICRO && getPlatform() !== CONST.PLATFORM.DESKTOP) {
optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.NVP_ONBOARDING,
value: {isLoading: true},
});

successData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.NVP_ONBOARDING,
value: {isLoading: false},
});

failureData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.NVP_ONBOARDING,
value: {isLoading: false},
});
}

API.write(WRITE_COMMANDS.COMPLETE_GUIDED_SETUP, parameters, {optimisticData, successData, failureData});
}

Expand Down
27 changes: 22 additions & 5 deletions src/pages/OnboardingEmployees/BaseOnboardingEmployees.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import HybridAppModule from '@expensify/react-native-hybrid-app';
import React, {useContext, useMemo, useState} from 'react';
import React, {useContext, useEffect, useMemo, useState} from 'react';
import {useOnyx} from 'react-native-onyx';
import Button from '@components/Button';
import CustomStatusBarAndBackgroundContext from '@components/CustomStatusBarAndBackground/CustomStatusBarAndBackgroundContext';
Expand All @@ -11,6 +11,8 @@ import RadioListItem from '@components/SelectionList/RadioListItem';
import type {ListItem} from '@components/SelectionList/types';
import Text from '@components/Text';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import usePrevious from '@hooks/usePrevious';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useThemeStyles from '@hooks/useThemeStyles';
import getPlatform from '@libs/getPlatform';
Expand Down Expand Up @@ -40,6 +42,12 @@ function BaseOnboardingEmployees({shouldUseNativeStyles, route}: BaseOnboardingE
const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
const {setRootStatusBarEnabled} = useContext(CustomStatusBarAndBackgroundContext);

const [onboarding] = useOnyx(ONYXKEYS.NVP_ONBOARDING);
const {isOffline} = useNetwork();

const isLoading = onboarding?.isLoading;
const prevIsLoading = usePrevious(isLoading);

const paidGroupPolicy = Object.values(allPolicies ?? {}).find(isPaidGroupPolicy);

const {onboardingIsMediumOrLargerScreenWidth} = useResponsiveLayout();
Expand Down Expand Up @@ -109,17 +117,26 @@ function BaseOnboardingEmployees({shouldUseNativeStyles, route}: BaseOnboardingE
}

if (CONFIG.IS_HYBRID_APP) {
HybridAppModule.closeReactNativeApp({shouldSignOut: false, shouldSetNVP: true});
setRootStatusBarEnabled(false);
} else {
openOldDotLink(CONST.OLDDOT_URLS.INBOX, true);
return;
}
openOldDotLink(CONST.OLDDOT_URLS.INBOX, true);
}}
pressOnEnter
isLoading={isLoading}
isDisabled={isOffline && selectedCompanySize !== CONST.ONBOARDING_COMPANY_SIZE.MICRO && CONFIG.IS_HYBRID_APP}
/>
</>
);

useEffect(() => {
if (!!isLoading || !prevIsLoading || !CONFIG.IS_HYBRID_APP) {
return;
}

HybridAppModule.closeReactNativeApp({shouldSignOut: false, shouldSetNVP: true});
setRootStatusBarEnabled(false);
}, [isLoading, prevIsLoading, setRootStatusBarEnabled]);

return (
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
Expand Down
3 changes: 3 additions & 0 deletions src/types/onyx/Onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ type Onboarding = {

/** A Boolean that tells whether the user has seen navattic tour */
selfTourViewed?: boolean;

/** A Boolean that tells whether the onboarding flow is loading */
isLoading?: boolean;
};

export default Onboarding;