2021-02-04 19:15:23 +01:00
|
|
|
import React, { Component } from 'react';
|
2021-05-28 20:47:17 +02:00
|
|
|
import { Switch, Route, matchPath } from 'react-router-dom';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import classnames from 'classnames';
|
2019-10-29 17:12:41 +01:00
|
|
|
import {
|
|
|
|
NEW_ACCOUNT_ROUTE,
|
|
|
|
IMPORT_ACCOUNT_ROUTE,
|
|
|
|
CONNECT_HARDWARE_ROUTE,
|
2021-02-04 19:15:23 +01:00
|
|
|
} from '../../helpers/constants/routes';
|
|
|
|
import NewAccountCreateForm from './new-account.container';
|
|
|
|
import NewAccountImportForm from './import-account';
|
|
|
|
import ConnectHardwareForm from './connect-hardware';
|
2019-10-29 17:12:41 +01:00
|
|
|
|
|
|
|
export default class CreateAccountPage extends Component {
|
2021-05-28 20:47:17 +02:00
|
|
|
renderTabs() {
|
|
|
|
const {
|
|
|
|
history,
|
|
|
|
location: { pathname },
|
|
|
|
} = this.props;
|
|
|
|
const getClassNames = (path) =>
|
|
|
|
classnames('new-account__tabs__tab', {
|
|
|
|
'new-account__tabs__selected': matchPath(pathname, {
|
|
|
|
path,
|
|
|
|
exact: true,
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="new-account__tabs">
|
|
|
|
<div
|
|
|
|
className={getClassNames(NEW_ACCOUNT_ROUTE)}
|
|
|
|
onClick={() => history.push(NEW_ACCOUNT_ROUTE)}
|
|
|
|
>
|
|
|
|
{this.context.t('create')}
|
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
className={getClassNames(IMPORT_ACCOUNT_ROUTE)}
|
|
|
|
onClick={() => history.push(IMPORT_ACCOUNT_ROUTE)}
|
|
|
|
>
|
|
|
|
{this.context.t('import')}
|
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
className={getClassNames(CONNECT_HARDWARE_ROUTE)}
|
|
|
|
onClick={() => history.push(CONNECT_HARDWARE_ROUTE)}
|
|
|
|
>
|
|
|
|
{this.context.t('hardware')}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
render() {
|
2019-10-29 17:12:41 +01:00
|
|
|
return (
|
|
|
|
<div className="new-account">
|
2021-05-28 20:47:17 +02:00
|
|
|
<div className="new-account__header">
|
|
|
|
<div
|
|
|
|
className={`new-account__header ${this.context.t('newAccount')}`}
|
|
|
|
>
|
|
|
|
{this.renderTabs()}
|
|
|
|
</div>
|
|
|
|
</div>
|
2019-10-29 17:12:41 +01:00
|
|
|
<div className="new-account__form">
|
|
|
|
<Switch>
|
|
|
|
<Route
|
2019-11-19 00:23:41 +01:00
|
|
|
exact
|
2019-10-29 17:12:41 +01:00
|
|
|
path={NEW_ACCOUNT_ROUTE}
|
|
|
|
component={NewAccountCreateForm}
|
|
|
|
/>
|
|
|
|
<Route
|
2019-11-19 00:23:41 +01:00
|
|
|
exact
|
2019-10-29 17:12:41 +01:00
|
|
|
path={IMPORT_ACCOUNT_ROUTE}
|
|
|
|
component={NewAccountImportForm}
|
|
|
|
/>
|
|
|
|
<Route
|
2019-11-19 00:23:41 +01:00
|
|
|
exact
|
2019-10-29 17:12:41 +01:00
|
|
|
path={CONNECT_HARDWARE_ROUTE}
|
|
|
|
component={ConnectHardwareForm}
|
|
|
|
/>
|
|
|
|
</Switch>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2019-10-29 17:12:41 +01:00
|
|
|
}
|
|
|
|
}
|
2021-05-28 20:47:17 +02:00
|
|
|
|
|
|
|
CreateAccountPage.propTypes = {
|
|
|
|
location: PropTypes.object,
|
|
|
|
history: PropTypes.object,
|
|
|
|
};
|
|
|
|
|
|
|
|
CreateAccountPage.contextTypes = {
|
|
|
|
t: PropTypes.func,
|
|
|
|
};
|