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.
137 lines
4.0 KiB
137 lines
4.0 KiB
4 years ago
|
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';
|
||
6 years ago
|
|
||
|
export default class EndOfFlowScreen extends PureComponent {
|
||
|
static contextTypes = {
|
||
|
t: PropTypes.func,
|
||
6 years ago
|
metricsEvent: PropTypes.func,
|
||
4 years ago
|
};
|
||
6 years ago
|
|
||
|
static propTypes = {
|
||
|
history: PropTypes.object,
|
||
6 years ago
|
completionMetaMetricsName: PropTypes.string,
|
||
4 years ago
|
setCompletedOnboarding: PropTypes.func,
|
||
5 years ago
|
onboardingInitiator: PropTypes.exact({
|
||
|
location: PropTypes.string,
|
||
|
tabId: PropTypes.number,
|
||
|
}),
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
4 years ago
|
async _beforeUnload() {
|
||
4 years ago
|
await this._onOnboardingComplete();
|
||
4 years ago
|
}
|
||
|
|
||
|
_removeBeforeUnload() {
|
||
4 years ago
|
window.removeEventListener('beforeunload', this._beforeUnload);
|
||
4 years ago
|
}
|
||
5 years ago
|
|
||
4 years ago
|
async _onOnboardingComplete() {
|
||
4 years ago
|
const { setCompletedOnboarding, completionMetaMetricsName } = this.props;
|
||
|
await setCompletedOnboarding();
|
||
5 years ago
|
this.context.metricsEvent({
|
||
|
eventOpts: {
|
||
|
category: 'Onboarding',
|
||
|
action: 'Onboarding Complete',
|
||
|
name: completionMetaMetricsName,
|
||
|
},
|
||
4 years ago
|
});
|
||
4 years ago
|
}
|
||
5 years ago
|
|
||
4 years ago
|
onComplete = async () => {
|
||
4 years ago
|
const { history, onboardingInitiator } = this.props;
|
||
4 years ago
|
|
||
4 years ago
|
this._removeBeforeUnload();
|
||
|
await this._onOnboardingComplete();
|
||
5 years ago
|
if (onboardingInitiator) {
|
||
4 years ago
|
await returnToOnboardingInitiator(onboardingInitiator);
|
||
5 years ago
|
}
|
||
4 years ago
|
history.push(DEFAULT_ROUTE);
|
||
|
};
|
||
6 years ago
|
|
||
4 years ago
|
componentDidMount() {
|
||
4 years ago
|
window.addEventListener('beforeunload', this._beforeUnload.bind(this));
|
||
4 years ago
|
}
|
||
|
|
||
|
componentWillUnmount = () => {
|
||
4 years ago
|
this._removeBeforeUnload();
|
||
|
};
|
||
4 years ago
|
|
||
4 years ago
|
render() {
|
||
4 years ago
|
const { t } = this.context;
|
||
|
const { onboardingInitiator } = this.props;
|
||
6 years ago
|
|
||
|
return (
|
||
|
<div className="end-of-flow">
|
||
5 years ago
|
<MetaFoxLogo />
|
||
6 years ago
|
<div className="end-of-flow__emoji">🎉</div>
|
||
4 years ago
|
<div className="first-time-flow__header">{t('congratulations')}</div>
|
||
6 years ago
|
<div className="first-time-flow__text-block end-of-flow__text-1">
|
||
4 years ago
|
{t('endOfFlowMessage1')}
|
||
6 years ago
|
</div>
|
||
|
<div className="first-time-flow__text-block end-of-flow__text-2">
|
||
4 years ago
|
{t('endOfFlowMessage2')}
|
||
6 years ago
|
</div>
|
||
6 years ago
|
<div className="end-of-flow__text-3">
|
||
4 years ago
|
{`• ${t('endOfFlowMessage3')}`}
|
||
6 years ago
|
</div>
|
||
6 years ago
|
<div className="end-of-flow__text-3">
|
||
4 years ago
|
{`• ${t('endOfFlowMessage4')}`}
|
||
6 years ago
|
</div>
|
||
6 years ago
|
<div className="end-of-flow__text-3">
|
||
4 years ago
|
{`• ${t('endOfFlowMessage5')}`}
|
||
6 years ago
|
</div>
|
||
|
<div className="end-of-flow__text-3">
|
||
4 years ago
|
{`• ${t('endOfFlowMessage6')}`}
|
||
6 years ago
|
</div>
|
||
6 years ago
|
<div className="end-of-flow__text-3">
|
||
4 years ago
|
•{' '}
|
||
|
{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>,
|
||
|
])}
|
||
6 years ago
|
</div>
|
||
|
<div className="first-time-flow__text-block end-of-flow__text-4">
|
||
4 years ago
|
{`*${t('endOfFlowMessage8')}`}
|
||
5 years ago
|
<a
|
||
6 years ago
|
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">
|
||
5 years ago
|
{t('endOfFlowMessage9')}
|
||
6 years ago
|
</span>
|
||
5 years ago
|
</a>
|
||
6 years ago
|
</div>
|
||
|
<Button
|
||
6 years ago
|
type="primary"
|
||
6 years ago
|
className="first-time-flow__button"
|
||
5 years ago
|
onClick={this.onComplete}
|
||
6 years ago
|
>
|
||
4 years ago
|
{t('endOfFlowMessage10')}
|
||
6 years ago
|
</Button>
|
||
4 years ago
|
{onboardingInitiator ? (
|
||
|
<Snackbar
|
||
|
content={t('onboardingReturnNotice', [
|
||
|
t('endOfFlowMessage10'),
|
||
|
onboardingInitiator.location,
|
||
|
])}
|
||
|
/>
|
||
|
) : null}
|
||
6 years ago
|
</div>
|
||
4 years ago
|
);
|
||
6 years ago
|
}
|
||
|
}
|