import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import { createNewVaultAndRestore, unMarkPasswordForgotten, initializeThreeBox, } from '../../store/actions'; import { DEFAULT_ROUTE } from '../../helpers/constants/routes'; import CreateNewVault from '../../components/app/create-new-vault'; class RestoreVaultPage extends Component { static contextTypes = { t: PropTypes.func, metricsEvent: PropTypes.func, }; static propTypes = { createNewVaultAndRestore: PropTypes.func.isRequired, leaveImportSeedScreenState: PropTypes.func, history: PropTypes.object, isLoading: PropTypes.bool, initializeThreeBox: PropTypes.func, }; handleImport = async (password, seedPhrase) => { const { // eslint-disable-next-line no-shadow createNewVaultAndRestore, leaveImportSeedScreenState, history, // eslint-disable-next-line no-shadow initializeThreeBox, } = this.props; leaveImportSeedScreenState(); await createNewVaultAndRestore(password, seedPhrase); this.context.metricsEvent({ eventOpts: { category: 'Retention', action: 'userEntersSeedPhrase', name: 'onboardingRestoredVault', }, }); initializeThreeBox(); history.push(DEFAULT_ROUTE); }; render() { const { t } = this.context; const { isLoading } = this.props; return (
{ e.preventDefault(); this.props.leaveImportSeedScreenState(); this.props.history.goBack(); }} href="#" > {`< ${t('back')}`}
{this.context.t('restoreAccountWithSeed')}
{this.context.t('secretPhrase')}
{this.context.t('secretPhraseWarning')}
); } } export default connect( ({ appState: { isLoading } }) => ({ isLoading }), (dispatch) => ({ leaveImportSeedScreenState: () => { dispatch(unMarkPasswordForgotten()); }, createNewVaultAndRestore: (pw, seed) => dispatch(createNewVaultAndRestore(pw, seed)), initializeThreeBox: () => dispatch(initializeThreeBox()), }), )(RestoreVaultPage);