blob: 7b64d4895ed4a45ea8ec8ab19ebec7d5b163e4f4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import React from 'react'
import PropTypes from 'prop-types'
import { Redirect, Route } from 'react-router-dom'
import { UNLOCK_ROUTE, INITIALIZE_ROUTE } from '../../routes'
export default function Authenticated (props) {
const { isUnlocked, completedOnboarding } = props
switch (true) {
case isUnlocked && completedOnboarding:
return <Route { ...props } />
case !completedOnboarding:
return <Redirect to={{ pathname: INITIALIZE_ROUTE }} />
default:
return <Redirect to={{ pathname: UNLOCK_ROUTE }} />
}
}
Authenticated.propTypes = {
isUnlocked: PropTypes.bool,
completedOnboarding: PropTypes.bool,
}
|