import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; import { createNewVaultAndRestore, unMarkPasswordForgotten, } from '../../store/actions'; import { DEFAULT_ROUTE } from '../../helpers/constants/routes'; import CreateNewVault from '../../components/app/create-new-vault'; import Button from '../../components/ui/button'; import Box from '../../components/ui/box'; import Typography from '../../components/ui/typography'; import ZENDESK_URLS from '../../helpers/constants/zendesk-url'; import { TextColor, TypographyVariant, } from '../../helpers/constants/design-system'; import { MetaMetricsEventCategory } from '../../../shared/constants/metametrics'; class RestoreVaultPage extends Component { static contextTypes = { t: PropTypes.func, trackEvent: PropTypes.func, }; static propTypes = { createNewVaultAndRestore: PropTypes.func.isRequired, leaveImportSeedScreenState: PropTypes.func, history: PropTypes.object, isLoading: PropTypes.bool, }; handleImport = async (password, seedPhrase) => { const { // eslint-disable-next-line no-shadow createNewVaultAndRestore, leaveImportSeedScreenState, history, } = this.props; leaveImportSeedScreenState(); await createNewVaultAndRestore(password, seedPhrase); this.context.trackEvent({ category: MetaMetricsEventCategory.Retention, event: 'onboardingRestoredVault', properties: { action: 'userEntersSeedPhrase', legacy_event: true, }, }); history.push(DEFAULT_ROUTE); }; render() { const { t } = this.context; const { isLoading } = this.props; return ( { e.preventDefault(); this.props.leaveImportSeedScreenState(); this.props.history.push(DEFAULT_ROUTE); }} href="#" > {`< ${t('back')}`} {t('resetWallet')} {t('resetWalletSubHeader')} {t('resetWalletUsingSRP', [ , , , ])} {t('resetWalletWarning')} ); } } export default connect( ({ appState: { isLoading } }) => ({ isLoading }), (dispatch) => ({ leaveImportSeedScreenState: () => { dispatch(unMarkPasswordForgotten()); }, createNewVaultAndRestore: (pw, seed) => dispatch(createNewVaultAndRestore(pw, seed)), }), )(RestoreVaultPage);