diff options
Diffstat (limited to 'ui/app/components/pages/first-time-flow/first-time-flow-switch/first-time-flow-switch.component.js')
-rw-r--r-- | ui/app/components/pages/first-time-flow/first-time-flow-switch/first-time-flow-switch.component.js | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/ui/app/components/pages/first-time-flow/first-time-flow-switch/first-time-flow-switch.component.js b/ui/app/components/pages/first-time-flow/first-time-flow-switch/first-time-flow-switch.component.js new file mode 100644 index 000000000..9e8bce2c8 --- /dev/null +++ b/ui/app/components/pages/first-time-flow/first-time-flow-switch/first-time-flow-switch.component.js @@ -0,0 +1,57 @@ +import React, { PureComponent } from 'react' +import PropTypes from 'prop-types' +import { Redirect } from 'react-router-dom' +import { + DEFAULT_ROUTE, + LOCK_ROUTE, + INITIALIZE_WELCOME_ROUTE, + INITIALIZE_NOTICE_ROUTE, + INITIALIZE_UNLOCK_ROUTE, + INITIALIZE_SEED_PHRASE_ROUTE, +} from '../../../../routes' + +export default class FirstTimeFlowSwitch extends PureComponent { + static propTypes = { + completedOnboarding: PropTypes.bool, + isInitialized: PropTypes.bool, + isUnlocked: PropTypes.bool, + noActiveNotices: PropTypes.bool, + seedPhrase: PropTypes.string, + } + + render () { + const { + completedOnboarding, + isInitialized, + isUnlocked, + noActiveNotices, + seedPhrase, + } = this.props + + if (completedOnboarding) { + return <Redirect to={{ pathname: DEFAULT_ROUTE }} /> + } + + if (isUnlocked && !seedPhrase) { + return <Redirect to={{ pathname: LOCK_ROUTE }} /> + } + + if (!isInitialized) { + return <Redirect to={{ pathname: INITIALIZE_WELCOME_ROUTE }} /> + } + + if (!isUnlocked) { + return <Redirect to={{ pathname: INITIALIZE_UNLOCK_ROUTE }} /> + } + + if (!noActiveNotices) { + return <Redirect to={{ pathname: INITIALIZE_NOTICE_ROUTE }} /> + } + + if (seedPhrase) { + return <Redirect to={{ pathname: INITIALIZE_SEED_PHRASE_ROUTE }} /> + } + + return <Redirect to={{ pathname: INITIALIZE_WELCOME_ROUTE }} /> + } +} |