2021-02-04 19:15:23 +01:00
|
|
|
import React, { PureComponent } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import Button from '../../../components/ui/button';
|
|
|
|
import Snackbar from '../../../components/ui/snackbar';
|
|
|
|
import MetaFoxLogo from '../../../components/ui/metafox-logo';
|
|
|
|
import { DEFAULT_ROUTE } from '../../../helpers/constants/routes';
|
|
|
|
import { returnToOnboardingInitiator } from '../onboarding-initiator-util';
|
2019-02-27 15:46:41 +01:00
|
|
|
|
|
|
|
export default class EndOfFlowScreen extends PureComponent {
|
|
|
|
static contextTypes = {
|
|
|
|
t: PropTypes.func,
|
2019-03-05 16:45:01 +01:00
|
|
|
metricsEvent: PropTypes.func,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-02-27 15:46:41 +01:00
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
history: PropTypes.object,
|
2019-03-05 16:45:01 +01:00
|
|
|
completionMetaMetricsName: PropTypes.string,
|
2020-11-13 19:22:58 +01:00
|
|
|
setCompletedOnboarding: PropTypes.func,
|
2019-11-22 18:03:51 +01:00
|
|
|
onboardingInitiator: PropTypes.exact({
|
|
|
|
location: PropTypes.string,
|
|
|
|
tabId: PropTypes.number,
|
|
|
|
}),
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-11-22 18:03:51 +01:00
|
|
|
|
2020-11-10 22:27:08 +01:00
|
|
|
async _beforeUnload() {
|
2021-02-04 19:15:23 +01:00
|
|
|
await this._onOnboardingComplete();
|
2020-11-10 22:27:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
_removeBeforeUnload() {
|
2021-02-04 19:15:23 +01:00
|
|
|
window.removeEventListener('beforeunload', this._beforeUnload);
|
2020-11-10 22:27:08 +01:00
|
|
|
}
|
2019-11-22 18:03:51 +01:00
|
|
|
|
2020-11-10 22:27:08 +01:00
|
|
|
async _onOnboardingComplete() {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { setCompletedOnboarding, completionMetaMetricsName } = this.props;
|
|
|
|
await setCompletedOnboarding();
|
2019-11-22 18:03:51 +01:00
|
|
|
this.context.metricsEvent({
|
|
|
|
eventOpts: {
|
|
|
|
category: 'Onboarding',
|
|
|
|
action: 'Onboarding Complete',
|
|
|
|
name: completionMetaMetricsName,
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-11-10 22:27:08 +01:00
|
|
|
}
|
2019-11-22 18:03:51 +01:00
|
|
|
|
2020-11-10 22:27:08 +01:00
|
|
|
onComplete = async () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { history, onboardingInitiator } = this.props;
|
2020-11-10 22:27:08 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
this._removeBeforeUnload();
|
|
|
|
await this._onOnboardingComplete();
|
2019-11-22 18:03:51 +01:00
|
|
|
if (onboardingInitiator) {
|
2021-02-04 19:15:23 +01:00
|
|
|
await returnToOnboardingInitiator(onboardingInitiator);
|
2019-11-22 18:03:51 +01:00
|
|
|
}
|
2021-02-04 19:15:23 +01:00
|
|
|
history.push(DEFAULT_ROUTE);
|
|
|
|
};
|
2019-02-27 15:46:41 +01:00
|
|
|
|
2020-11-10 22:27:08 +01:00
|
|
|
componentDidMount() {
|
2021-02-04 19:15:23 +01:00
|
|
|
window.addEventListener('beforeunload', this._beforeUnload.bind(this));
|
2020-11-10 22:27:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount = () => {
|
2021-02-04 19:15:23 +01:00
|
|
|
this._removeBeforeUnload();
|
|
|
|
};
|
2020-11-10 22:27:08 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
render() {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { t } = this.context;
|
|
|
|
const { onboardingInitiator } = this.props;
|
2019-02-27 15:46:41 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="end-of-flow">
|
2021-10-28 21:59:20 +02:00
|
|
|
<MetaFoxLogo />
|
2019-02-27 15:46:41 +01:00
|
|
|
<div className="end-of-flow__emoji">🎉</div>
|
2020-11-03 00:41:28 +01:00
|
|
|
<div className="first-time-flow__header">{t('congratulations')}</div>
|
2019-02-27 15:46:41 +01:00
|
|
|
<div className="first-time-flow__text-block end-of-flow__text-1">
|
2020-11-03 00:41:28 +01:00
|
|
|
{t('endOfFlowMessage1')}
|
2019-02-27 15:46:41 +01:00
|
|
|
</div>
|
|
|
|
<div className="first-time-flow__text-block end-of-flow__text-2">
|
2020-11-03 00:41:28 +01:00
|
|
|
{t('endOfFlowMessage2')}
|
2019-02-27 15:46:41 +01:00
|
|
|
</div>
|
2019-03-05 16:45:01 +01:00
|
|
|
<div className="end-of-flow__text-3">
|
2020-11-03 00:41:28 +01:00
|
|
|
{`• ${t('endOfFlowMessage3')}`}
|
2019-02-27 15:46:41 +01:00
|
|
|
</div>
|
2019-03-05 16:45:01 +01:00
|
|
|
<div className="end-of-flow__text-3">
|
2020-11-03 00:41:28 +01:00
|
|
|
{`• ${t('endOfFlowMessage4')}`}
|
2019-02-27 15:46:41 +01:00
|
|
|
</div>
|
2019-03-05 16:45:01 +01:00
|
|
|
<div className="end-of-flow__text-3">
|
2020-11-03 00:41:28 +01:00
|
|
|
{`• ${t('endOfFlowMessage5')}`}
|
2019-03-05 16:45:01 +01:00
|
|
|
</div>
|
|
|
|
<div className="end-of-flow__text-3">
|
2020-11-03 00:41:28 +01:00
|
|
|
{`• ${t('endOfFlowMessage6')}`}
|
2019-02-27 15:46:41 +01:00
|
|
|
</div>
|
2019-03-05 16:45:01 +01:00
|
|
|
<div className="end-of-flow__text-3">
|
2021-03-03 18:15:24 +01:00
|
|
|
•{' '}
|
|
|
|
{t('endOfFlowMessage7', [
|
|
|
|
<a
|
|
|
|
target="_blank"
|
|
|
|
key="metamaskSupportLink"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
href="https://metamask.zendesk.com/hc/en-us/requests/new"
|
|
|
|
>
|
|
|
|
<span className="first-time-flow__link-text">
|
|
|
|
{this.context.t('here')}
|
|
|
|
</span>
|
|
|
|
</a>,
|
|
|
|
])}
|
2019-03-05 16:45:01 +01:00
|
|
|
</div>
|
|
|
|
<div className="first-time-flow__text-block end-of-flow__text-4">
|
2020-11-03 00:41:28 +01:00
|
|
|
{`*${t('endOfFlowMessage8')}`}
|
2019-12-03 17:35:44 +01:00
|
|
|
<a
|
2019-03-05 16:45:01 +01:00
|
|
|
href="https://metamask.zendesk.com/hc/en-us/articles/360015489591-Basic-Safety-Tips"
|
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
>
|
|
|
|
<span className="first-time-flow__link-text">
|
2019-07-15 04:22:20 +02:00
|
|
|
{t('endOfFlowMessage9')}
|
2019-03-05 16:45:01 +01:00
|
|
|
</span>
|
2019-07-15 18:48:44 +02:00
|
|
|
</a>
|
2019-02-27 15:46:41 +01:00
|
|
|
</div>
|
|
|
|
<Button
|
2019-04-16 21:35:22 +02:00
|
|
|
type="primary"
|
2019-02-27 15:46:41 +01:00
|
|
|
className="first-time-flow__button"
|
2019-11-22 18:03:51 +01:00
|
|
|
onClick={this.onComplete}
|
2019-02-27 15:46:41 +01:00
|
|
|
>
|
2020-11-03 00:41:28 +01:00
|
|
|
{t('endOfFlowMessage10')}
|
2019-02-27 15:46:41 +01:00
|
|
|
</Button>
|
2020-11-03 00:41:28 +01:00
|
|
|
{onboardingInitiator ? (
|
|
|
|
<Snackbar
|
|
|
|
content={t('onboardingReturnNotice', [
|
|
|
|
t('endOfFlowMessage10'),
|
|
|
|
onboardingInitiator.location,
|
|
|
|
])}
|
|
|
|
/>
|
|
|
|
) : null}
|
2019-02-27 15:46:41 +01:00
|
|
|
</div>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2019-02-27 15:46:41 +01:00
|
|
|
}
|
|
|
|
}
|