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 MetaFoxLogo from '../../../components/ui/metafox-logo';
|
2022-08-18 23:31:07 +02:00
|
|
|
import { EVENT, EVENT_NAMES } from '../../../../shared/constants/metametrics';
|
2022-07-22 22:39:48 +02:00
|
|
|
import {
|
|
|
|
INITIALIZE_CREATE_PASSWORD_ROUTE,
|
|
|
|
INITIALIZE_IMPORT_WITH_SEED_PHRASE_ROUTE,
|
|
|
|
} from '../../../helpers/constants/routes';
|
2019-02-27 15:46:41 +01:00
|
|
|
|
|
|
|
export default class SelectAction extends PureComponent {
|
|
|
|
static propTypes = {
|
|
|
|
history: PropTypes.object,
|
|
|
|
isInitialized: PropTypes.bool,
|
2019-03-05 16:45:01 +01:00
|
|
|
setFirstTimeFlowType: PropTypes.func,
|
|
|
|
nextRoute: PropTypes.string,
|
2022-08-16 00:42:08 +02:00
|
|
|
metaMetricsId: PropTypes.string,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-02-27 15:46:41 +01:00
|
|
|
|
|
|
|
static contextTypes = {
|
2022-08-16 00:42:08 +02:00
|
|
|
trackEvent: PropTypes.func,
|
2019-02-27 15:46:41 +01:00
|
|
|
t: PropTypes.func,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-02-27 15:46:41 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
componentDidMount() {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { history, isInitialized, nextRoute } = this.props;
|
2019-02-27 15:46:41 +01:00
|
|
|
|
|
|
|
if (isInitialized) {
|
2021-02-04 19:15:23 +01:00
|
|
|
history.push(nextRoute);
|
2019-02-27 15:46:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
handleCreate = () => {
|
2022-08-16 00:42:08 +02:00
|
|
|
const { metaMetricsId } = this.props;
|
|
|
|
const { trackEvent } = this.context;
|
2021-02-04 19:15:23 +01:00
|
|
|
this.props.setFirstTimeFlowType('create');
|
2022-08-16 00:42:08 +02:00
|
|
|
trackEvent(
|
|
|
|
{
|
|
|
|
category: EVENT.CATEGORIES.ONBOARDING,
|
2022-08-18 23:31:07 +02:00
|
|
|
event: EVENT_NAMES.WALLET_SETUP_STARTED,
|
2022-08-16 00:42:08 +02:00
|
|
|
properties: {
|
2022-08-18 23:31:07 +02:00
|
|
|
account_type: EVENT.ACCOUNT_TYPES.DEFAULT,
|
2022-08-16 00:42:08 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
isOptIn: true,
|
|
|
|
metaMetricsId,
|
|
|
|
flushImmediately: true,
|
|
|
|
},
|
|
|
|
);
|
2022-07-22 22:39:48 +02:00
|
|
|
this.props.history.push(INITIALIZE_CREATE_PASSWORD_ROUTE);
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-02-27 15:46:41 +01:00
|
|
|
|
|
|
|
handleImport = () => {
|
2022-08-16 00:42:08 +02:00
|
|
|
const { metaMetricsId } = this.props;
|
|
|
|
const { trackEvent } = this.context;
|
2021-02-04 19:15:23 +01:00
|
|
|
this.props.setFirstTimeFlowType('import');
|
2022-08-16 00:42:08 +02:00
|
|
|
trackEvent(
|
|
|
|
{
|
|
|
|
category: EVENT.CATEGORIES.ONBOARDING,
|
2022-08-18 23:31:07 +02:00
|
|
|
event: EVENT_NAMES.WALLET_SETUP_STARTED,
|
2022-08-16 00:42:08 +02:00
|
|
|
properties: {
|
2022-08-18 23:31:07 +02:00
|
|
|
account_type: EVENT.ACCOUNT_TYPES.IMPORTED,
|
2022-08-16 00:42:08 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
isOptIn: true,
|
|
|
|
metaMetricsId,
|
|
|
|
flushImmediately: true,
|
|
|
|
},
|
|
|
|
);
|
2022-07-22 22:39:48 +02:00
|
|
|
this.props.history.push(INITIALIZE_IMPORT_WITH_SEED_PHRASE_ROUTE);
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-02-27 15:46:41 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
render() {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { t } = this.context;
|
2019-02-27 15:46:41 +01:00
|
|
|
|
|
|
|
return (
|
2019-07-31 22:17:11 +02:00
|
|
|
<div className="select-action">
|
2021-10-28 21:59:20 +02:00
|
|
|
<MetaFoxLogo />
|
2019-02-27 15:46:41 +01:00
|
|
|
|
|
|
|
<div className="select-action__wrapper">
|
|
|
|
<div className="select-action__body">
|
|
|
|
<div className="select-action__body-header">
|
2020-11-03 00:41:28 +01:00
|
|
|
{t('newToMetaMask')}
|
2019-02-27 15:46:41 +01:00
|
|
|
</div>
|
|
|
|
<div className="select-action__select-buttons">
|
|
|
|
<div className="select-action__select-button">
|
|
|
|
<div className="select-action__button-content">
|
|
|
|
<div className="select-action__button-symbol">
|
2022-03-24 01:05:55 +01:00
|
|
|
<i className="fa fa-download fa-2x" />
|
2019-02-27 15:46:41 +01:00
|
|
|
</div>
|
|
|
|
<div className="select-action__button-text-big">
|
2020-11-03 00:41:28 +01:00
|
|
|
{t('noAlreadyHaveSeed')}
|
2019-02-27 15:46:41 +01:00
|
|
|
</div>
|
2019-03-05 16:45:01 +01:00
|
|
|
<div className="select-action__button-text-small">
|
2020-11-03 00:41:28 +01:00
|
|
|
{t('importYourExisting')}
|
2019-03-05 16:45:01 +01:00
|
|
|
</div>
|
2019-02-27 15:46:41 +01:00
|
|
|
</div>
|
|
|
|
<Button
|
|
|
|
type="primary"
|
|
|
|
className="first-time-flow__button"
|
|
|
|
onClick={this.handleImport}
|
2022-08-09 17:37:29 +02:00
|
|
|
data-testid="import-wallet-button"
|
2019-02-27 15:46:41 +01:00
|
|
|
>
|
2020-11-03 00:41:28 +01:00
|
|
|
{t('importWallet')}
|
2019-02-27 15:46:41 +01:00
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
<div className="select-action__select-button">
|
|
|
|
<div className="select-action__button-content">
|
|
|
|
<div className="select-action__button-symbol">
|
2022-03-24 01:05:55 +01:00
|
|
|
<i className="fa fa-plus fa-2x" />
|
2019-02-27 15:46:41 +01:00
|
|
|
</div>
|
|
|
|
<div className="select-action__button-text-big">
|
2020-11-03 00:41:28 +01:00
|
|
|
{t('letsGoSetUp')}
|
2019-02-27 15:46:41 +01:00
|
|
|
</div>
|
2019-03-05 16:45:01 +01:00
|
|
|
<div className="select-action__button-text-small">
|
2020-11-03 00:41:28 +01:00
|
|
|
{t('thisWillCreate')}
|
2019-03-05 16:45:01 +01:00
|
|
|
</div>
|
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"
|
|
|
|
onClick={this.handleCreate}
|
2022-08-09 17:37:29 +02:00
|
|
|
data-testid="create-wallet-button"
|
2019-02-27 15:46:41 +01:00
|
|
|
>
|
2020-11-03 00:41:28 +01:00
|
|
|
{t('createAWallet')}
|
2019-02-27 15:46:41 +01:00
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2019-07-31 22:17:11 +02:00
|
|
|
</div>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2019-02-27 15:46:41 +01:00
|
|
|
}
|
|
|
|
}
|