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'; 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 { TYPOGRAPHY, COLORS } from '../../helpers/constants/design-system'; 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, 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.trackEvent({ category: 'Retention', event: 'onboardingRestoredVault', properties: { action: 'userEntersSeedPhrase', legacy_event: true, }, }); 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')}`} {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)), initializeThreeBox: () => dispatch(initializeThreeBox()), }), )(RestoreVaultPage);