2021-02-04 19:15:23 +01:00
|
|
|
import React, { PureComponent } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2019-01-23 16:25:34 +01:00
|
|
|
import {
|
2019-02-27 15:46:41 +01:00
|
|
|
INITIALIZE_SELECT_ACTION_ROUTE,
|
2019-03-05 16:45:01 +01:00
|
|
|
INITIALIZE_END_OF_FLOW_ROUTE,
|
2021-02-04 19:15:23 +01:00
|
|
|
} from '../../../../helpers/constants/routes';
|
2022-02-03 15:06:43 +01:00
|
|
|
import CreateNewVault from '../../../../components/app/create-new-vault';
|
2020-09-28 23:13:42 +02:00
|
|
|
|
2019-01-23 16:25:34 +01:00
|
|
|
export default class ImportWithSeedPhrase extends PureComponent {
|
|
|
|
static contextTypes = {
|
|
|
|
t: PropTypes.func,
|
2022-03-29 15:46:24 +02:00
|
|
|
trackEvent: PropTypes.func,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-01-23 16:25:34 +01:00
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
history: PropTypes.object,
|
|
|
|
onSubmit: PropTypes.func.isRequired,
|
2019-08-02 05:57:26 +02:00
|
|
|
setSeedPhraseBackedUp: PropTypes.func,
|
2019-09-16 19:11:01 +02:00
|
|
|
initializeThreeBox: PropTypes.func,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-01-23 16:25:34 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
UNSAFE_componentWillMount() {
|
|
|
|
this._onBeforeUnload = () =>
|
2022-03-29 15:46:24 +02:00
|
|
|
this.context.trackEvent({
|
|
|
|
category: 'Onboarding',
|
|
|
|
event: 'Close window on import screen',
|
|
|
|
properties: {
|
2020-11-03 00:41:28 +01:00
|
|
|
action: 'Import Seed Phrase',
|
2022-03-29 15:46:24 +02:00
|
|
|
legacy_event: true,
|
2020-11-03 00:41:28 +01:00
|
|
|
errorLabel: 'Seed Phrase Error',
|
|
|
|
errorMessage: this.state.seedPhraseError,
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
window.addEventListener('beforeunload', this._onBeforeUnload);
|
2019-10-31 17:27:22 +01:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
componentWillUnmount() {
|
2021-02-04 19:15:23 +01:00
|
|
|
window.removeEventListener('beforeunload', this._onBeforeUnload);
|
2019-04-05 05:16:25 +02:00
|
|
|
}
|
|
|
|
|
2022-02-03 15:06:43 +01:00
|
|
|
handleImport = async (password, seedPhrase) => {
|
2020-11-03 00:41:28 +01:00
|
|
|
const {
|
|
|
|
history,
|
|
|
|
onSubmit,
|
|
|
|
setSeedPhraseBackedUp,
|
|
|
|
initializeThreeBox,
|
2021-02-04 19:15:23 +01:00
|
|
|
} = this.props;
|
2019-01-23 16:25:34 +01:00
|
|
|
|
2022-02-03 15:06:43 +01:00
|
|
|
await onSubmit(password, seedPhrase);
|
2022-03-29 15:46:24 +02:00
|
|
|
this.context.trackEvent({
|
|
|
|
category: 'Onboarding',
|
|
|
|
event: 'Import Complete',
|
|
|
|
properties: {
|
2019-03-05 16:45:01 +01:00
|
|
|
action: 'Import Seed Phrase',
|
2022-03-29 15:46:24 +02:00
|
|
|
legacy_event: true,
|
2019-03-05 16:45:01 +01:00
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2019-02-27 15:46:41 +01:00
|
|
|
|
2022-02-03 15:06:43 +01:00
|
|
|
await setSeedPhraseBackedUp(true);
|
|
|
|
initializeThreeBox();
|
|
|
|
history.replace(INITIALIZE_END_OF_FLOW_ROUTE);
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-06-11 16:24:13 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
render() {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { t } = this.context;
|
2019-01-23 16:25:34 +01:00
|
|
|
|
|
|
|
return (
|
2022-02-03 15:06:43 +01:00
|
|
|
<div className="first-time-flow__import">
|
2019-02-27 15:46:41 +01:00
|
|
|
<div className="first-time-flow__create-back">
|
2019-01-23 16:25:34 +01:00
|
|
|
<a
|
2020-02-15 21:34:12 +01:00
|
|
|
onClick={(e) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
e.preventDefault();
|
2022-03-29 15:46:24 +02:00
|
|
|
this.context.trackEvent({
|
|
|
|
category: 'Onboarding',
|
|
|
|
event: 'Go Back from Onboarding Import',
|
|
|
|
properties: {
|
2019-03-05 16:45:01 +01:00
|
|
|
action: 'Import Seed Phrase',
|
2022-03-29 15:46:24 +02:00
|
|
|
legacy_event: true,
|
2019-03-05 16:45:01 +01:00
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
this.props.history.push(INITIALIZE_SELECT_ACTION_ROUTE);
|
2019-01-23 16:25:34 +01:00
|
|
|
}}
|
|
|
|
href="#"
|
|
|
|
>
|
2021-06-08 19:02:34 +02:00
|
|
|
{`< ${t('back')}`}
|
2019-01-23 16:25:34 +01:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<div className="first-time-flow__header">
|
2020-11-03 00:41:28 +01:00
|
|
|
{t('importAccountSeedPhrase')}
|
2019-01-23 16:25:34 +01:00
|
|
|
</div>
|
2020-11-03 00:41:28 +01:00
|
|
|
<div className="first-time-flow__text-block">{t('secretPhrase')}</div>
|
2022-02-03 15:06:43 +01:00
|
|
|
<CreateNewVault
|
|
|
|
includeTerms
|
|
|
|
onSubmit={this.handleImport}
|
|
|
|
submitText={t('import')}
|
2019-01-23 16:25:34 +01:00
|
|
|
/>
|
2022-02-03 15:06:43 +01:00
|
|
|
</div>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2019-01-23 16:25:34 +01:00
|
|
|
}
|
|
|
|
}
|