You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
193 lines
5.4 KiB
193 lines
5.4 KiB
4 years ago
|
import React, { PureComponent } from 'react';
|
||
|
import PropTypes from 'prop-types';
|
||
|
import classnames from 'classnames';
|
||
|
import LockIcon from '../../../../components/ui/lock-icon';
|
||
|
import Button from '../../../../components/ui/button';
|
||
|
import Snackbar from '../../../../components/ui/snackbar';
|
||
4 years ago
|
import {
|
||
|
INITIALIZE_CONFIRM_SEED_PHRASE_ROUTE,
|
||
|
DEFAULT_ROUTE,
|
||
4 years ago
|
} from '../../../../helpers/constants/routes';
|
||
|
import { exportAsFile } from '../../../../helpers/utils/util';
|
||
|
import { returnToOnboardingInitiator } from '../../onboarding-initiator-util';
|
||
6 years ago
|
|
||
|
export default class RevealSeedPhrase extends PureComponent {
|
||
|
static contextTypes = {
|
||
|
t: PropTypes.func,
|
||
6 years ago
|
metricsEvent: PropTypes.func,
|
||
4 years ago
|
};
|
||
6 years ago
|
|
||
|
static propTypes = {
|
||
|
history: PropTypes.object,
|
||
|
seedPhrase: PropTypes.string,
|
||
5 years ago
|
setSeedPhraseBackedUp: PropTypes.func,
|
||
|
setCompletedOnboarding: PropTypes.func,
|
||
5 years ago
|
onboardingInitiator: PropTypes.exact({
|
||
|
location: PropTypes.string,
|
||
|
tabId: PropTypes.number,
|
||
|
}),
|
||
4 years ago
|
};
|
||
6 years ago
|
|
||
|
state = {
|
||
|
isShowingSeedPhrase: false,
|
||
4 years ago
|
};
|
||
6 years ago
|
|
||
|
handleExport = () => {
|
||
4 years ago
|
exportAsFile('', this.props.seedPhrase, 'text/plain');
|
||
|
};
|
||
6 years ago
|
|
||
5 years ago
|
handleNext = () => {
|
||
4 years ago
|
const { isShowingSeedPhrase } = this.state;
|
||
|
const { history } = this.props;
|
||
6 years ago
|
|
||
6 years ago
|
this.context.metricsEvent({
|
||
|
eventOpts: {
|
||
|
category: 'Onboarding',
|
||
|
action: 'Seed Phrase Setup',
|
||
|
name: 'Advance to Verify',
|
||
|
},
|
||
4 years ago
|
});
|
||
6 years ago
|
|
||
6 years ago
|
if (!isShowingSeedPhrase) {
|
||
4 years ago
|
return;
|
||
6 years ago
|
}
|
||
|
|
||
4 years ago
|
history.push(INITIALIZE_CONFIRM_SEED_PHRASE_ROUTE);
|
||
|
};
|
||
6 years ago
|
|
||
5 years ago
|
handleSkip = async () => {
|
||
4 years ago
|
const {
|
||
|
history,
|
||
|
setSeedPhraseBackedUp,
|
||
|
setCompletedOnboarding,
|
||
|
onboardingInitiator,
|
||
4 years ago
|
} = this.props;
|
||
5 years ago
|
|
||
|
this.context.metricsEvent({
|
||
|
eventOpts: {
|
||
|
category: 'Onboarding',
|
||
|
action: 'Seed Phrase Setup',
|
||
|
name: 'Remind me later',
|
||
|
},
|
||
4 years ago
|
});
|
||
5 years ago
|
|
||
4 years ago
|
await Promise.all([setCompletedOnboarding(), setSeedPhraseBackedUp(false)]);
|
||
5 years ago
|
|
||
|
if (onboardingInitiator) {
|
||
4 years ago
|
await returnToOnboardingInitiator(onboardingInitiator);
|
||
5 years ago
|
}
|
||
4 years ago
|
history.push(DEFAULT_ROUTE);
|
||
|
};
|
||
5 years ago
|
|
||
4 years ago
|
renderSecretWordsContainer() {
|
||
4 years ago
|
const { t } = this.context;
|
||
|
const { seedPhrase } = this.props;
|
||
|
const { isShowingSeedPhrase } = this.state;
|
||
6 years ago
|
|
||
|
return (
|
||
|
<div className="reveal-seed-phrase__secret">
|
||
5 years ago
|
<div
|
||
|
className={classnames(
|
||
4 years ago
|
'reveal-seed-phrase__secret-words notranslate',
|
||
|
{
|
||
5 years ago
|
'reveal-seed-phrase__secret-words--hidden': !isShowingSeedPhrase,
|
||
4 years ago
|
},
|
||
|
)}
|
||
5 years ago
|
>
|
||
4 years ago
|
{seedPhrase}
|
||
6 years ago
|
</div>
|
||
4 years ago
|
{!isShowingSeedPhrase && (
|
||
|
<div
|
||
|
className="reveal-seed-phrase__secret-blocker"
|
||
|
onClick={() => {
|
||
|
this.context.metricsEvent({
|
||
|
eventOpts: {
|
||
|
category: 'Onboarding',
|
||
|
action: 'Seed Phrase Setup',
|
||
|
name: 'Revealed Words',
|
||
|
},
|
||
4 years ago
|
});
|
||
|
this.setState({ isShowingSeedPhrase: true });
|
||
4 years ago
|
}}
|
||
|
>
|
||
|
<LockIcon width="28px" height="35px" fill="#FFFFFF" />
|
||
|
<div className="reveal-seed-phrase__reveal-button">
|
||
|
{t('clickToRevealSeed')}
|
||
6 years ago
|
</div>
|
||
4 years ago
|
</div>
|
||
|
)}
|
||
6 years ago
|
</div>
|
||
4 years ago
|
);
|
||
6 years ago
|
}
|
||
|
|
||
4 years ago
|
render() {
|
||
4 years ago
|
const { t } = this.context;
|
||
|
const { isShowingSeedPhrase } = this.state;
|
||
|
const { onboardingInitiator } = this.props;
|
||
6 years ago
|
|
||
|
return (
|
||
6 years ago
|
<div className="reveal-seed-phrase">
|
||
6 years ago
|
<div className="seed-phrase__sections">
|
||
|
<div className="seed-phrase__main">
|
||
|
<div className="first-time-flow__header">
|
||
4 years ago
|
{t('secretBackupPhrase')}
|
||
6 years ago
|
</div>
|
||
|
<div className="first-time-flow__text-block">
|
||
4 years ago
|
{t('secretBackupPhraseDescription')}
|
||
6 years ago
|
</div>
|
||
|
<div className="first-time-flow__text-block">
|
||
4 years ago
|
{t('secretBackupPhraseWarning')}
|
||
6 years ago
|
</div>
|
||
4 years ago
|
{this.renderSecretWordsContainer()}
|
||
6 years ago
|
</div>
|
||
|
<div className="seed-phrase__side">
|
||
4 years ago
|
<div className="first-time-flow__text-block">{`${t('tips')}:`}</div>
|
||
6 years ago
|
<div className="first-time-flow__text-block">
|
||
4 years ago
|
{t('storePhrase')}
|
||
6 years ago
|
</div>
|
||
|
<div className="first-time-flow__text-block">
|
||
4 years ago
|
{t('writePhrase')}
|
||
6 years ago
|
</div>
|
||
|
<div className="first-time-flow__text-block">
|
||
4 years ago
|
{t('memorizePhrase')}
|
||
6 years ago
|
</div>
|
||
|
<div className="first-time-flow__text-block">
|
||
|
<a
|
||
|
className="reveal-seed-phrase__export-text"
|
||
5 years ago
|
onClick={this.handleExport}
|
||
|
>
|
||
4 years ago
|
{t('downloadSecretBackup')}
|
||
6 years ago
|
</a>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
5 years ago
|
<div className="reveal-seed-phrase__buttons">
|
||
|
<Button
|
||
|
type="secondary"
|
||
|
className="first-time-flow__button"
|
||
|
onClick={this.handleSkip}
|
||
|
>
|
||
4 years ago
|
{t('remindMeLater')}
|
||
5 years ago
|
</Button>
|
||
|
<Button
|
||
|
type="primary"
|
||
|
className="first-time-flow__button"
|
||
|
onClick={this.handleNext}
|
||
|
disabled={!isShowingSeedPhrase}
|
||
|
>
|
||
4 years ago
|
{t('next')}
|
||
5 years ago
|
</Button>
|
||
|
</div>
|
||
4 years ago
|
{onboardingInitiator ? (
|
||
|
<Snackbar
|
||
|
content={t('onboardingReturnNotice', [
|
||
|
t('remindMeLater'),
|
||
|
onboardingInitiator.location,
|
||
|
])}
|
||
|
/>
|
||
|
) : null}
|
||
6 years ago
|
</div>
|
||
4 years ago
|
);
|
||
6 years ago
|
}
|
||
|
}
|