2021-02-04 19:15:23 +01:00
|
|
|
import EventEmitter from 'events';
|
|
|
|
import React, { PureComponent } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import Mascot from '../../../components/ui/mascot';
|
|
|
|
import Button from '../../../components/ui/button';
|
2020-11-03 00:41:28 +01:00
|
|
|
import {
|
|
|
|
INITIALIZE_CREATE_PASSWORD_ROUTE,
|
|
|
|
INITIALIZE_SELECT_ACTION_ROUTE,
|
2022-07-22 22:39:48 +02:00
|
|
|
INITIALIZE_METAMETRICS_OPT_IN_ROUTE,
|
2021-02-04 19:15:23 +01:00
|
|
|
} from '../../../helpers/constants/routes';
|
2021-09-08 22:08:23 +02:00
|
|
|
import { isBeta } from '../../../helpers/utils/build-types';
|
|
|
|
import WelcomeFooter from './welcome-footer.component';
|
|
|
|
import BetaWelcomeFooter from './beta-welcome-footer.component';
|
2019-01-23 16:25:34 +01:00
|
|
|
|
|
|
|
export default class Welcome extends PureComponent {
|
|
|
|
static propTypes = {
|
|
|
|
history: PropTypes.object,
|
2019-03-05 16:45:01 +01:00
|
|
|
participateInMetaMetrics: PropTypes.bool,
|
|
|
|
welcomeScreenSeen: PropTypes.bool,
|
2022-07-22 22:39:48 +02:00
|
|
|
isInitialized: PropTypes.bool,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-01-23 16:25:34 +01:00
|
|
|
|
|
|
|
static contextTypes = {
|
|
|
|
t: 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
|
|
|
constructor(props) {
|
2021-02-04 19:15:23 +01:00
|
|
|
super(props);
|
2019-01-23 16:25:34 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
this.animationEventEmitter = new EventEmitter();
|
2019-01-23 16:25:34 +01:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
componentDidMount() {
|
2022-07-22 22:39:48 +02:00
|
|
|
const {
|
|
|
|
history,
|
|
|
|
participateInMetaMetrics,
|
|
|
|
welcomeScreenSeen,
|
|
|
|
isInitialized,
|
|
|
|
} = this.props;
|
2019-01-23 16:25:34 +01:00
|
|
|
|
2022-07-22 22:39:48 +02:00
|
|
|
if (
|
|
|
|
welcomeScreenSeen &&
|
|
|
|
isInitialized &&
|
|
|
|
participateInMetaMetrics !== null
|
|
|
|
) {
|
2021-02-04 19:15:23 +01:00
|
|
|
history.push(INITIALIZE_CREATE_PASSWORD_ROUTE);
|
2022-07-22 22:39:48 +02:00
|
|
|
} else if (welcomeScreenSeen && participateInMetaMetrics !== null) {
|
2021-02-04 19:15:23 +01:00
|
|
|
history.push(INITIALIZE_SELECT_ACTION_ROUTE);
|
2022-07-22 22:39:48 +02:00
|
|
|
} else if (welcomeScreenSeen) {
|
|
|
|
history.push(INITIALIZE_METAMETRICS_OPT_IN_ROUTE);
|
2019-01-23 16:25:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
handleContinue = () => {
|
2022-07-22 22:39:48 +02:00
|
|
|
this.props.history.push(INITIALIZE_METAMETRICS_OPT_IN_ROUTE);
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-01-23 16:25:34 +01: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 (
|
|
|
|
<div className="welcome-page__wrapper">
|
|
|
|
<div className="welcome-page">
|
|
|
|
<Mascot
|
|
|
|
animationEventEmitter={this.animationEventEmitter}
|
2019-02-27 15:46:41 +01:00
|
|
|
width="125"
|
|
|
|
height="125"
|
2019-01-23 16:25:34 +01:00
|
|
|
/>
|
2021-09-08 22:08:23 +02:00
|
|
|
{isBeta() ? <BetaWelcomeFooter /> : <WelcomeFooter />}
|
2019-01-23 16:25:34 +01:00
|
|
|
<Button
|
2019-04-16 21:35:22 +02:00
|
|
|
type="primary"
|
2019-01-23 16:25:34 +01:00
|
|
|
className="first-time-flow__button"
|
|
|
|
onClick={this.handleContinue}
|
2022-09-08 19:05:15 +02:00
|
|
|
data-testid="first-time-flow__button"
|
2019-01-23 16:25:34 +01:00
|
|
|
>
|
2020-11-03 00:41:28 +01:00
|
|
|
{t('getStarted')}
|
2019-01-23 16:25:34 +01:00
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2019-01-23 16:25:34 +01:00
|
|
|
}
|
|
|
|
}
|