2019-02-27 15:46:41 +01:00
|
|
|
import React, { PureComponent } from 'react'
|
|
|
|
import PropTypes from 'prop-types'
|
2019-03-22 00:03:30 +01:00
|
|
|
import Button from '../../../components/ui/button'
|
2019-11-22 18:03:51 +01:00
|
|
|
import Snackbar from '../../../components/ui/snackbar'
|
2019-07-09 19:17:58 +02:00
|
|
|
import MetaFoxLogo from '../../../components/ui/metafox-logo'
|
2019-03-22 00:03:30 +01:00
|
|
|
import { DEFAULT_ROUTE } from '../../../helpers/constants/routes'
|
2019-11-22 18:03:51 +01:00
|
|
|
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,
|
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-10 22:27:08 +01:00
|
|
|
setCompletedOnboarding: PropTypes.function,
|
2019-11-22 18:03:51 +01:00
|
|
|
onboardingInitiator: PropTypes.exact({
|
|
|
|
location: PropTypes.string,
|
|
|
|
tabId: PropTypes.number,
|
|
|
|
}),
|
|
|
|
}
|
|
|
|
|
2020-11-10 22:27:08 +01:00
|
|
|
async _beforeUnload() {
|
|
|
|
await this._onOnboardingComplete()
|
|
|
|
}
|
|
|
|
|
|
|
|
_removeBeforeUnload() {
|
|
|
|
window.removeEventListener('beforeunload', this._beforeUnload)
|
|
|
|
}
|
2019-11-22 18:03:51 +01:00
|
|
|
|
2020-11-10 22:27:08 +01:00
|
|
|
async _onOnboardingComplete() {
|
|
|
|
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,
|
|
|
|
},
|
|
|
|
})
|
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 () => {
|
|
|
|
const { history, onboardingInitiator } = this.props
|
|
|
|
|
|
|
|
this._removeBeforeUnload()
|
|
|
|
await this._onOnboardingComplete()
|
2019-11-22 18:03:51 +01:00
|
|
|
if (onboardingInitiator) {
|
|
|
|
await returnToOnboardingInitiator(onboardingInitiator)
|
|
|
|
}
|
|
|
|
history.push(DEFAULT_ROUTE)
|
2019-02-27 15:46:41 +01:00
|
|
|
}
|
|
|
|
|
2020-11-10 22:27:08 +01:00
|
|
|
componentDidMount() {
|
|
|
|
window.addEventListener('beforeunload', this._beforeUnload.bind(this))
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount = () => {
|
|
|
|
this._removeBeforeUnload()
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
render() {
|
2019-02-27 15:46:41 +01:00
|
|
|
const { t } = this.context
|
2019-11-22 18:03:51 +01:00
|
|
|
const { onboardingInitiator } = this.props
|
2019-02-27 15:46:41 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="end-of-flow">
|
2019-07-09 19:17:58 +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">
|
2020-11-03 00:41:28 +01:00
|
|
|
{`• ${t('endOfFlowMessage7')}`}
|
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>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|