2021-02-04 19:15:23 +01:00
|
|
|
import React, { PureComponent } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { Switch, Route } from 'react-router-dom';
|
|
|
|
import MetaFoxLogo from '../../../components/ui/metafox-logo';
|
2019-01-23 16:25:34 +01:00
|
|
|
import {
|
|
|
|
INITIALIZE_CREATE_PASSWORD_ROUTE,
|
|
|
|
INITIALIZE_IMPORT_WITH_SEED_PHRASE_ROUTE,
|
2019-03-11 20:22:26 +01:00
|
|
|
INITIALIZE_SEED_PHRASE_ROUTE,
|
2021-02-04 19:15:23 +01:00
|
|
|
} from '../../../helpers/constants/routes';
|
|
|
|
import NewAccount from './new-account';
|
|
|
|
import ImportWithSeedPhrase from './import-with-seed-phrase';
|
2019-01-23 16:25:34 +01:00
|
|
|
|
|
|
|
export default class CreatePassword extends PureComponent {
|
|
|
|
static propTypes = {
|
|
|
|
history: PropTypes.object,
|
|
|
|
isInitialized: PropTypes.bool,
|
|
|
|
onCreateNewAccount: PropTypes.func,
|
|
|
|
onCreateNewAccountFromSeed: PropTypes.func,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-01-23 16:25:34 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
componentDidMount() {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { isInitialized, history } = this.props;
|
2019-01-23 16:25:34 +01:00
|
|
|
|
|
|
|
if (isInitialized) {
|
2021-02-04 19:15:23 +01:00
|
|
|
history.push(INITIALIZE_SEED_PHRASE_ROUTE);
|
2019-01-23 16:25:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
render() {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { onCreateNewAccount, onCreateNewAccountFromSeed } = this.props;
|
2019-01-23 16:25:34 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="first-time-flow__wrapper">
|
2019-07-09 19:17:58 +02:00
|
|
|
<MetaFoxLogo />
|
2019-01-23 16:25:34 +01:00
|
|
|
<Switch>
|
|
|
|
<Route
|
|
|
|
exact
|
|
|
|
path={INITIALIZE_IMPORT_WITH_SEED_PHRASE_ROUTE}
|
2020-02-15 21:34:12 +01:00
|
|
|
render={(routeProps) => (
|
2019-01-23 16:25:34 +01:00
|
|
|
<ImportWithSeedPhrase
|
2020-11-03 00:41:28 +01:00
|
|
|
{...routeProps}
|
2019-01-23 16:25:34 +01:00
|
|
|
onSubmit={onCreateNewAccountFromSeed}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
<Route
|
|
|
|
exact
|
|
|
|
path={INITIALIZE_CREATE_PASSWORD_ROUTE}
|
2020-02-15 21:34:12 +01:00
|
|
|
render={(routeProps) => (
|
2020-11-03 00:41:28 +01:00
|
|
|
<NewAccount {...routeProps} onSubmit={onCreateNewAccount} />
|
2019-01-23 16:25:34 +01:00
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</Switch>
|
|
|
|
</div>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2019-01-23 16:25:34 +01:00
|
|
|
}
|
|
|
|
}
|