1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-11 20:27:12 +01:00
metamask-extension/ui/selectors/first-time-flow.js
Alex Donesky 71f91568db
Migrate completedOnboarding and firstTimeFlowType state into onboardingController (#12356)
* migrate completedOnboarding state into onboardingController

* migrate firstTimeFlowType state from preferencesController to onboardingController
2021-10-15 13:52:52 -05:00

46 lines
1.1 KiB
JavaScript

import {
INITIALIZE_CREATE_PASSWORD_ROUTE,
INITIALIZE_IMPORT_WITH_SEED_PHRASE_ROUTE,
DEFAULT_ROUTE,
ONBOARDING_CREATE_PASSWORD_ROUTE,
ONBOARDING_IMPORT_WITH_SRP_ROUTE,
} from '../helpers/constants/routes';
export function getFirstTimeFlowTypeRoute(state) {
const { firstTimeFlowType } = state.metamask;
let nextRoute;
if (firstTimeFlowType === 'create') {
nextRoute = process.env.ONBOARDING_V2
? ONBOARDING_CREATE_PASSWORD_ROUTE
: INITIALIZE_CREATE_PASSWORD_ROUTE;
} else if (firstTimeFlowType === 'import') {
nextRoute = process.env.ONBOARDING_V2
? ONBOARDING_IMPORT_WITH_SRP_ROUTE
: INITIALIZE_IMPORT_WITH_SEED_PHRASE_ROUTE;
} else {
nextRoute = DEFAULT_ROUTE;
}
return nextRoute;
}
export const getFirstTimeFlowType = (state) => {
return state.metamask.firstTimeFlowType;
};
export const getOnboardingInitiator = (state) => {
const { onboardingTabs } = state.metamask;
if (!onboardingTabs || Object.keys(onboardingTabs).length !== 1) {
return null;
}
const location = Object.keys(onboardingTabs)[0];
const tabId = onboardingTabs[location];
return {
location,
tabId,
};
};