import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; import Box from '../../../../components/ui/box'; import LockIcon from '../../../../components/ui/lock-icon'; import Button from '../../../../components/ui/button'; import Snackbar from '../../../../components/ui/snackbar'; import { INITIALIZE_CONFIRM_SEED_PHRASE_ROUTE, DEFAULT_ROUTE, INITIALIZE_SEED_PHRASE_INTRO_ROUTE, } from '../../../../helpers/constants/routes'; import { exportAsFile } from '../../../../helpers/utils/util'; import { EVENT } from '../../../../../shared/constants/metametrics'; import { returnToOnboardingInitiator } from '../../onboarding-initiator-util'; export default class RevealSeedPhrase extends PureComponent { static contextTypes = { t: PropTypes.func, trackEvent: PropTypes.func, }; static propTypes = { history: PropTypes.object, seedPhrase: PropTypes.string, setSeedPhraseBackedUp: PropTypes.func, setCompletedOnboarding: PropTypes.func, onboardingInitiator: PropTypes.exact({ location: PropTypes.string, tabId: PropTypes.number, }), }; state = { isShowingSeedPhrase: false, }; handleExport = () => { exportAsFile('', this.props.seedPhrase, 'text/plain'); }; handleNext = () => { const { isShowingSeedPhrase } = this.state; const { history } = this.props; this.context.trackEvent({ category: EVENT.CATEGORIES.ONBOARDING, event: 'Advance to Verify', properties: { action: 'Seed Phrase Setup', legacy_event: true, }, }); if (!isShowingSeedPhrase) { return; } history.replace(INITIALIZE_CONFIRM_SEED_PHRASE_ROUTE); }; handleSkip = async () => { const { history, setSeedPhraseBackedUp, setCompletedOnboarding, onboardingInitiator, } = this.props; this.context.trackEvent({ category: EVENT.CATEGORIES.ONBOARDING, event: 'Remind me later', properties: { action: 'Seed Phrase Setup', legacy_event: true, }, }); await Promise.all([setCompletedOnboarding(), setSeedPhraseBackedUp(false)]); if (onboardingInitiator) { await returnToOnboardingInitiator(onboardingInitiator); } history.replace(DEFAULT_ROUTE); }; renderSecretWordsContainer() { const { t } = this.context; const { seedPhrase } = this.props; const { isShowingSeedPhrase } = this.state; return (
{seedPhrase}
{!isShowingSeedPhrase && (
{ this.context.trackEvent({ category: EVENT.CATEGORIES.ONBOARDING, event: 'Revealed Words', properties: { action: 'Seed Phrase Setup', legacy_event: true, }, }); this.setState({ isShowingSeedPhrase: true }); }} >
{t('clickToRevealSeed')}
)}
); } render() { const { t } = this.context; const { isShowingSeedPhrase } = this.state; const { history, onboardingInitiator } = this.props; return (
{ e.preventDefault(); history.push(INITIALIZE_SEED_PHRASE_INTRO_ROUTE); }} > {`< ${t('back')}`}
{t('secretRecoveryPhrase')}
{t('secretBackupPhraseDescription')}
{t('secretBackupPhraseWarning')}
{this.renderSecretWordsContainer()}
{`${t('tips')}:`}
{t('storePhrase')}
{t('writePhrase')}
{t('memorizePhrase')}
{t('downloadSecretBackup')}
{onboardingInitiator ? ( ) : null}
); } }