2021-02-04 19:15:23 +01:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
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 {
|
2020-11-03 00:41:28 +01:00
|
|
|
renderTabs() {
|
|
|
|
const {
|
|
|
|
history,
|
|
|
|
location: { pathname },
|
2021-02-04 19:15:23 +01:00
|
|
|
} = this.props;
|
2020-11-03 00:41:28 +01:00
|
|
|
const getClassNames = (path) =>
|
|
|
|
classnames('new-account__tabs__tab', {
|
|
|
|
'new-account__tabs__selected': matchPath(pathname, {
|
|
|
|
path,
|
|
|
|
exact: true,
|
|
|
|
}),
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2019-10-29 17:12:41 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="new-account__tabs">
|
2020-11-03 00:41:28 +01:00
|
|
|
<div
|
|
|
|
className={getClassNames(NEW_ACCOUNT_ROUTE)}
|
|
|
|
onClick={() => history.push(NEW_ACCOUNT_ROUTE)}
|
|
|
|
>
|
2019-12-03 17:35:44 +01:00
|
|
|
{this.context.t('create')}
|
|
|
|
</div>
|
2020-11-03 00:41:28 +01:00
|
|
|
<div
|
|
|
|
className={getClassNames(IMPORT_ACCOUNT_ROUTE)}
|
|
|
|
onClick={() => history.push(IMPORT_ACCOUNT_ROUTE)}
|
|
|
|
>
|
2019-12-03 17:35:44 +01:00
|
|
|
{this.context.t('import')}
|
|
|
|
</div>
|
2020-11-03 00:41:28 +01:00
|
|
|
<div
|
|
|
|
className={getClassNames(CONNECT_HARDWARE_ROUTE)}
|
|
|
|
onClick={() => history.push(CONNECT_HARDWARE_ROUTE)}
|
|
|
|
>
|
2020-05-28 20:47:48 +02:00
|
|
|
{this.context.t('hardware')}
|
2019-12-03 17:35:44 +01:00
|
|
|
</div>
|
2019-10-29 17:12:41 +01:00
|
|
|
</div>
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2019-10-29 17:12:41 +01:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
render() {
|
2019-10-29 17:12:41 +01:00
|
|
|
return (
|
|
|
|
<div className="new-account">
|
|
|
|
<div className="new-account__header">
|
2020-11-03 00:41:28 +01:00
|
|
|
<div
|
|
|
|
className={`new-account__header ${this.context.t('newAccount')}`}
|
|
|
|
>
|
2019-10-29 17:12:41 +01:00
|
|
|
{this.renderTabs()}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CreateAccountPage.propTypes = {
|
|
|
|
location: PropTypes.object,
|
|
|
|
history: PropTypes.object,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-10-29 17:12:41 +01:00
|
|
|
|
|
|
|
CreateAccountPage.contextTypes = {
|
|
|
|
t: PropTypes.func,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|