2019-01-23 16:25:34 +01:00
|
|
|
import React, { PureComponent } from 'react'
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
import { Redirect } from 'react-router-dom'
|
|
|
|
import {
|
|
|
|
DEFAULT_ROUTE,
|
2020-11-09 14:50:24 +01:00
|
|
|
LOCK_ROUTE,
|
2020-11-10 22:27:08 +01:00
|
|
|
INITIALIZE_END_OF_FLOW_ROUTE,
|
2019-01-23 16:25:34 +01:00
|
|
|
INITIALIZE_WELCOME_ROUTE,
|
|
|
|
INITIALIZE_UNLOCK_ROUTE,
|
2019-03-22 00:03:30 +01:00
|
|
|
} from '../../../helpers/constants/routes'
|
2019-01-23 16:25:34 +01:00
|
|
|
|
|
|
|
export default class FirstTimeFlowSwitch extends PureComponent {
|
|
|
|
static propTypes = {
|
|
|
|
completedOnboarding: PropTypes.bool,
|
|
|
|
isInitialized: PropTypes.bool,
|
2020-11-09 14:50:24 +01:00
|
|
|
isUnlocked: PropTypes.bool,
|
2020-11-10 22:27:08 +01:00
|
|
|
seedPhraseBackedUp: PropTypes.bool,
|
2019-01-23 16:25:34 +01:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
render() {
|
2020-11-10 22:27:08 +01:00
|
|
|
const {
|
|
|
|
completedOnboarding,
|
|
|
|
isInitialized,
|
|
|
|
isUnlocked,
|
|
|
|
seedPhraseBackedUp,
|
|
|
|
} = this.props
|
2019-01-23 16:25:34 +01:00
|
|
|
|
|
|
|
if (completedOnboarding) {
|
|
|
|
return <Redirect to={{ pathname: DEFAULT_ROUTE }} />
|
|
|
|
}
|
|
|
|
|
2020-11-10 22:27:08 +01:00
|
|
|
if (seedPhraseBackedUp !== null) {
|
|
|
|
return <Redirect to={{ pathname: INITIALIZE_END_OF_FLOW_ROUTE }} />
|
|
|
|
}
|
|
|
|
|
2020-11-09 14:50:24 +01:00
|
|
|
if (isUnlocked) {
|
|
|
|
return <Redirect to={{ pathname: LOCK_ROUTE }} />
|
|
|
|
}
|
|
|
|
|
2019-01-23 16:25:34 +01:00
|
|
|
if (!isInitialized) {
|
|
|
|
return <Redirect to={{ pathname: INITIALIZE_WELCOME_ROUTE }} />
|
|
|
|
}
|
|
|
|
|
2020-11-05 17:11:56 +01:00
|
|
|
return <Redirect to={{ pathname: INITIALIZE_UNLOCK_ROUTE }} />
|
2019-01-23 16:25:34 +01:00
|
|
|
}
|
|
|
|
}
|