You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.4 KiB
58 lines
1.4 KiB
6 years ago
|
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_UNLOCK_ROUTE,
|
||
|
INITIALIZE_SEED_PHRASE_ROUTE,
|
||
6 years ago
|
INITIALIZE_METAMETRICS_OPT_IN_ROUTE,
|
||
6 years ago
|
} from '../../../helpers/constants/routes'
|
||
6 years ago
|
|
||
|
export default class FirstTimeFlowSwitch extends PureComponent {
|
||
|
static propTypes = {
|
||
|
completedOnboarding: PropTypes.bool,
|
||
|
isInitialized: PropTypes.bool,
|
||
|
isUnlocked: PropTypes.bool,
|
||
|
seedPhrase: PropTypes.string,
|
||
6 years ago
|
optInMetaMetrics: PropTypes.bool,
|
||
6 years ago
|
}
|
||
|
|
||
|
render () {
|
||
|
const {
|
||
|
completedOnboarding,
|
||
|
isInitialized,
|
||
|
isUnlocked,
|
||
|
seedPhrase,
|
||
6 years ago
|
optInMetaMetrics,
|
||
6 years ago
|
} = 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 (seedPhrase) {
|
||
|
return <Redirect to={{ pathname: INITIALIZE_SEED_PHRASE_ROUTE }} />
|
||
|
}
|
||
|
|
||
6 years ago
|
if (optInMetaMetrics === null) {
|
||
|
return <Redirect to={{ pathname: INITIALIZE_WELCOME_ROUTE }} />
|
||
|
}
|
||
|
|
||
|
return <Redirect to={{ pathname: INITIALIZE_METAMETRICS_OPT_IN_ROUTE }} />
|
||
6 years ago
|
}
|
||
|
}
|