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';
|
2022-01-06 01:55:20 +01:00
|
|
|
import { SUPPORT_REQUEST_LINK } from '../../../helpers/constants/common';
|
2021-02-04 19:15:23 +01:00
|
|
|
import { DEFAULT_ROUTE } from '../../../helpers/constants/routes';
|
2022-04-29 16:21:06 +02:00
|
|
|
import { returnToOnboardingInitiatorTab } from '../onboarding-initiator-util';
|
2022-08-11 19:33:33 +02:00
|
|
|
import {
|
|
|
|
EVENT,
|
|
|
|
EVENT_NAMES,
|
|
|
|
CONTEXT_PROPS,
|
|
|
|
} from '../../../../shared/constants/metametrics';
|
2022-08-23 16:19:31 +02:00
|
|
|
import ZENDESK_URLS from '../../../helpers/constants/zendesk-url';
|
2019-02-27 15:46:41 +01:00
|
|
|
|
|
|
|
export default class EndOfFlowScreen extends PureComponent {
|
|
|
|
static contextTypes = {
|
|
|
|
t: PropTypes.func,
|
2022-03-29 15:46:24 +02:00
|
|
|
trackEvent: PropTypes.func,
|
2022-10-04 17:52:42 +02:00
|
|
|
setOnBoardedInThisUISession: PropTypes.func,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-02-27 15:46:41 +01:00
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
history: PropTypes.object,
|
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,
|
|
|
|
}),
|
2022-10-04 17:52:42 +02:00
|
|
|
setOnBoardedInThisUISession: PropTypes.func,
|
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() {
|
2022-10-04 17:52:42 +02:00
|
|
|
const { setCompletedOnboarding, setOnBoardedInThisUISession } = this.props;
|
|
|
|
setOnBoardedInThisUISession(true);
|
2021-02-04 19:15:23 +01:00
|
|
|
await setCompletedOnboarding();
|
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) {
|
2022-04-29 16:21:06 +02:00
|
|
|
await returnToOnboardingInitiatorTab(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 (
|
2022-08-09 17:37:29 +02:00
|
|
|
<div className="end-of-flow" data-testid="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"
|
2022-01-06 01:55:20 +01:00
|
|
|
href={SUPPORT_REQUEST_LINK}
|
2022-08-11 19:33:33 +02:00
|
|
|
onClick={() => {
|
|
|
|
this.context.trackEvent(
|
|
|
|
{
|
|
|
|
category: EVENT.CATEGORIES.ONBOARDING,
|
|
|
|
event: EVENT_NAMES.SUPPORT_LINK_CLICKED,
|
|
|
|
properties: {
|
|
|
|
url: SUPPORT_REQUEST_LINK,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
contextPropsIntoEventProperties: [CONTEXT_PROPS.PAGE_TITLE],
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}}
|
2021-03-03 18:15:24 +01:00
|
|
|
>
|
|
|
|
<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
|
2022-08-23 16:19:31 +02:00
|
|
|
href={ZENDESK_URLS.BASIC_SAFETY}
|
2019-03-05 16:45:01 +01:00
|
|
|
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}
|
2022-08-09 17:37:29 +02:00
|
|
|
data-testid="EOF-complete-button"
|
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
|
|
|
}
|
|
|
|
}
|