Skip to content

Commit

Permalink
redirect user to concierge when onboarding completed
Browse files Browse the repository at this point in the history
  • Loading branch information
Skyweb331 committed May 13, 2024
1 parent 59e74e9 commit 2edff29
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,23 +1,41 @@
import {createStackNavigator} from '@react-navigation/stack';
import React from 'react';
import {View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';
import NoDropZone from '@components/DragAndDrop/NoDropZone';
import useOnboardingLayout from '@hooks/useOnboardingLayout';
import useThemeStyles from '@hooks/useThemeStyles';
import OnboardingModalNavigatorScreenOptions from '@libs/Navigation/AppNavigator/OnboardingModalNavigatorScreenOptions';
import Navigation from '@libs/Navigation/Navigation';
import type {OnboardingModalNavigatorParamList} from '@libs/Navigation/types';
import OnboardingPersonalDetails from '@pages/OnboardingPersonalDetails';
import OnboardingPurpose from '@pages/OnboardingPurpose';
import OnboardingWork from '@pages/OnboardingWork';
import * as Report from '@userActions/Report';
import ONYXKEYS from '@src/ONYXKEYS';
import SCREENS from '@src/SCREENS';
import type * as OnyxTypes from '@src/types/onyx';
import Overlay from './Overlay';

type OnboardingModalNavigatorProps = {
/** Current onboarding completion status */
onboarding: OnyxEntry<OnyxTypes.Onboarding>;
};

const Stack = createStackNavigator<OnboardingModalNavigatorParamList>();

function OnboardingModalNavigator() {
function OnboardingModalNavigator({onboarding}: OnboardingModalNavigatorProps) {
const styles = useThemeStyles();
const {shouldUseNarrowLayout} = useOnboardingLayout();

if (onboarding?.hasCompletedGuidedSetupFlow) {
Navigation.goBack();
Report.navigateToConciergeChat();
// eslint-disable-next-line react/jsx-no-useless-fragment
return <></>;
}

return (
<NoDropZone>
<Overlay />
Expand Down Expand Up @@ -45,4 +63,9 @@ function OnboardingModalNavigator() {

OnboardingModalNavigator.displayName = 'OnboardingModalNavigator';

export default OnboardingModalNavigator;
export default withOnyx<OnboardingModalNavigatorProps, OnboardingModalNavigatorProps>({
onboarding: {
key: ONYXKEYS.NVP_ONBOARDING,
selector: (onboarding) => onboarding as OnyxTypes.Onboarding,
},
})(OnboardingModalNavigator);
2 changes: 2 additions & 0 deletions src/types/onyx/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import type MapboxAccessToken from './MapboxAccessToken';
import type Modal from './Modal';
import type Network from './Network';
import type NewGroupChatDraft from './NewGroupChatDraft';
import type Onboarding from './Onboarding';
import type {OnyxUpdateEvent, OnyxUpdatesFromServer} from './OnyxUpdatesFromServer';
import type {DecisionName, OriginalMessageIOU} from './OriginalMessage';
import type PersonalBankAccount from './PersonalBankAccount';
Expand Down Expand Up @@ -108,6 +109,7 @@ export type {
MapboxAccessToken,
Modal,
Network,
Onboarding,
OnyxUpdateEvent,
OnyxUpdatesFromServer,
PersonalBankAccount,
Expand Down

0 comments on commit 2edff29

Please sign in to comment.