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.
101 lines
3.0 KiB
101 lines
3.0 KiB
4 years ago
|
import React, { PureComponent } from 'react';
|
||
|
import PropTypes from 'prop-types';
|
||
|
import { Switch, Route } from 'react-router-dom';
|
||
|
import HTML5Backend from 'react-dnd-html5-backend';
|
||
|
import { DragDropContextProvider } from 'react-dnd';
|
||
6 years ago
|
import {
|
||
|
INITIALIZE_SEED_PHRASE_ROUTE,
|
||
|
INITIALIZE_CONFIRM_SEED_PHRASE_ROUTE,
|
||
5 years ago
|
INITIALIZE_BACKUP_SEED_PHRASE_ROUTE,
|
||
4 years ago
|
INITIALIZE_SEED_PHRASE_INTRO_ROUTE,
|
||
6 years ago
|
DEFAULT_ROUTE,
|
||
4 years ago
|
} from '../../../helpers/constants/routes';
|
||
|
import MetaFoxLogo from '../../../components/ui/metafox-logo';
|
||
|
import ConfirmSeedPhrase from './confirm-seed-phrase';
|
||
|
import RevealSeedPhrase from './reveal-seed-phrase';
|
||
4 years ago
|
import SeedPhraseIntro from './seed-phrase-intro';
|
||
6 years ago
|
|
||
|
export default class SeedPhrase extends PureComponent {
|
||
|
static propTypes = {
|
||
|
history: PropTypes.object,
|
||
|
seedPhrase: PropTypes.string,
|
||
5 years ago
|
verifySeedPhrase: PropTypes.func,
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
|
state = {
|
||
|
verifiedSeedPhrase: '',
|
||
4 years ago
|
};
|
||
6 years ago
|
|
||
4 years ago
|
componentDidMount() {
|
||
4 years ago
|
const { seedPhrase, history, verifySeedPhrase } = this.props;
|
||
6 years ago
|
|
||
|
if (!seedPhrase) {
|
||
4 years ago
|
verifySeedPhrase().then((verifiedSeedPhrase) => {
|
||
|
if (verifiedSeedPhrase) {
|
||
4 years ago
|
this.setState({ verifiedSeedPhrase });
|
||
4 years ago
|
} else {
|
||
4 years ago
|
history.push(DEFAULT_ROUTE);
|
||
4 years ago
|
}
|
||
4 years ago
|
});
|
||
6 years ago
|
}
|
||
|
}
|
||
|
|
||
4 years ago
|
render() {
|
||
4 years ago
|
const { seedPhrase, history } = this.props;
|
||
4 years ago
|
const { verifiedSeedPhrase } = this.state;
|
||
4 years ago
|
const pathname = history?.location?.pathname;
|
||
|
const introClass =
|
||
|
pathname === INITIALIZE_SEED_PHRASE_INTRO_ROUTE ? 'intro' : '';
|
||
6 years ago
|
|
||
|
return (
|
||
6 years ago
|
<DragDropContextProvider backend={HTML5Backend}>
|
||
4 years ago
|
<div className={`first-time-flow__wrapper ${introClass}`}>
|
||
5 years ago
|
<MetaFoxLogo />
|
||
6 years ago
|
<Switch>
|
||
|
<Route
|
||
|
exact
|
||
|
path={INITIALIZE_CONFIRM_SEED_PHRASE_ROUTE}
|
||
5 years ago
|
render={(routeProps) => (
|
||
6 years ago
|
<ConfirmSeedPhrase
|
||
4 years ago
|
{...routeProps}
|
||
5 years ago
|
seedPhrase={seedPhrase || verifiedSeedPhrase}
|
||
6 years ago
|
/>
|
||
|
)}
|
||
|
/>
|
||
|
<Route
|
||
|
exact
|
||
|
path={INITIALIZE_SEED_PHRASE_ROUTE}
|
||
5 years ago
|
render={(routeProps) => (
|
||
6 years ago
|
<RevealSeedPhrase
|
||
4 years ago
|
{...routeProps}
|
||
5 years ago
|
seedPhrase={seedPhrase || verifiedSeedPhrase}
|
||
6 years ago
|
/>
|
||
|
)}
|
||
|
/>
|
||
5 years ago
|
<Route
|
||
|
exact
|
||
|
path={INITIALIZE_BACKUP_SEED_PHRASE_ROUTE}
|
||
5 years ago
|
render={(routeProps) => (
|
||
5 years ago
|
<RevealSeedPhrase
|
||
4 years ago
|
{...routeProps}
|
||
5 years ago
|
seedPhrase={seedPhrase || verifiedSeedPhrase}
|
||
|
/>
|
||
|
)}
|
||
|
/>
|
||
4 years ago
|
<Route
|
||
|
exact
|
||
|
path={INITIALIZE_SEED_PHRASE_INTRO_ROUTE}
|
||
|
render={(routeProps) => (
|
||
|
<SeedPhraseIntro
|
||
|
{...routeProps}
|
||
|
seedPhrase={seedPhrase || verifiedSeedPhrase}
|
||
|
/>
|
||
|
)}
|
||
|
/>
|
||
6 years ago
|
</Switch>
|
||
6 years ago
|
</div>
|
||
6 years ago
|
</DragDropContextProvider>
|
||
4 years ago
|
);
|
||
6 years ago
|
}
|
||
|
}
|