mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-29 23:58:06 +01:00
70386726f6
* Added Flask Experimental Area warning to OnboardingV2 * Added first time flow Flask Experimental Area warning * Made both onboarding flows use one Experimental Area component * Fix comments in React divs * Fix unreachable code * Fix build lint problems * Changes after code review * Added guards around route constants imports * Code Review changes * Update ui/components/app/flask/experimental-area/index.scss Co-authored-by: George Marshall <george.marshall@consensys.net> * Code review changes * Fix lint * Update ui/components/app/flask/experimental-area/index.scss Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/components/app/flask/experimental-area/index.scss Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/components/app/flask/experimental-area/index.scss Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/components/app/flask/experimental-area/index.scss Co-authored-by: George Marshall <george.marshall@consensys.net> * Update ui/components/app/flask/experimental-area/index.scss Co-authored-by: George Marshall <george.marshall@consensys.net> * fix lint Co-authored-by: George Marshall <george.marshall@consensys.net>
57 lines
1.7 KiB
JavaScript
57 lines
1.7 KiB
JavaScript
import React from 'react';
|
|
import { useSelector } from 'react-redux';
|
|
import { Redirect } from 'react-router-dom';
|
|
import {
|
|
DEFAULT_ROUTE,
|
|
ONBOARDING_COMPLETION_ROUTE,
|
|
ONBOARDING_UNLOCK_ROUTE,
|
|
LOCK_ROUTE,
|
|
///: BEGIN:ONLY_INCLUDE_IN(flask)
|
|
ONBOARDING_EXPERIMENTAL_AREA, // eslint-disable-line no-unused-vars
|
|
///: END:ONLY_INCLUDE_IN
|
|
///: BEGIN:ONLY_INCLUDE_IN(main,beta)
|
|
ONBOARDING_WELCOME_ROUTE, // eslint-disable-line no-unused-vars
|
|
///: END:ONLY_INCLUDE_IN
|
|
} from '../../../helpers/constants/routes';
|
|
import {
|
|
getCompletedOnboarding,
|
|
getIsInitialized,
|
|
getIsUnlocked,
|
|
getSeedPhraseBackedUp,
|
|
} from '../../../ducks/metamask/metamask';
|
|
|
|
export default function OnboardingFlowSwitch() {
|
|
/* eslint-disable prefer-const */
|
|
const completedOnboarding = useSelector(getCompletedOnboarding);
|
|
const isInitialized = useSelector(getIsInitialized);
|
|
const seedPhraseBackedUp = useSelector(getSeedPhraseBackedUp);
|
|
const isUnlocked = useSelector(getIsUnlocked);
|
|
|
|
if (completedOnboarding) {
|
|
return <Redirect to={{ pathname: DEFAULT_ROUTE }} />;
|
|
}
|
|
|
|
if (seedPhraseBackedUp !== null) {
|
|
return <Redirect to={{ pathname: ONBOARDING_COMPLETION_ROUTE }} />;
|
|
}
|
|
|
|
if (isUnlocked) {
|
|
return <Redirect to={{ pathname: LOCK_ROUTE }} />;
|
|
}
|
|
|
|
if (!isInitialized) {
|
|
let redirect;
|
|
/* eslint-disable prefer-const */
|
|
///: BEGIN:ONLY_INCLUDE_IN(flask)
|
|
redirect = <Redirect to={{ pathname: ONBOARDING_EXPERIMENTAL_AREA }} />;
|
|
///: END:ONLY_INCLUDE_IN
|
|
///: BEGIN:ONLY_INCLUDE_IN(main,beta)
|
|
redirect = <Redirect to={{ pathname: ONBOARDING_WELCOME_ROUTE }} />;
|
|
///: END:ONLY_INCLUDE_IN
|
|
/* eslint-enable prefer-const */
|
|
return redirect;
|
|
}
|
|
|
|
return <Redirect to={{ pathname: ONBOARDING_UNLOCK_ROUTE }} />;
|
|
}
|