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 { returnToOnboardingInitiatorTab } 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 returnToOnboardingInitiatorTab(onboardingInitiator); } history.replace(DEFAULT_ROUTE); }; renderSecretWordsContainer() { const { t } = this.context; const { seedPhrase } = this.props; const { isShowingSeedPhrase } = this.state; return (