2019-10-29 17:12:41 +01:00
|
|
|
import React, { Component } from 'react'
|
|
|
|
import { Switch, Route, matchPath } from 'react-router-dom'
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
import classnames from 'classnames'
|
|
|
|
import {
|
|
|
|
NEW_ACCOUNT_ROUTE,
|
|
|
|
IMPORT_ACCOUNT_ROUTE,
|
|
|
|
CONNECT_HARDWARE_ROUTE,
|
|
|
|
} from '../../helpers/constants/routes'
|
2020-08-18 21:18:25 +02:00
|
|
|
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 },
|
|
|
|
} = this.props
|
|
|
|
const getClassNames = (path) =>
|
|
|
|
classnames('new-account__tabs__tab', {
|
|
|
|
'new-account__tabs__selected': matchPath(pathname, {
|
|
|
|
path,
|
|
|
|
exact: true,
|
|
|
|
}),
|
|
|
|
})
|
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>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
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>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CreateAccountPage.propTypes = {
|
|
|
|
location: PropTypes.object,
|
|
|
|
history: PropTypes.object,
|
|
|
|
}
|
|
|
|
|
|
|
|
CreateAccountPage.contextTypes = {
|
|
|
|
t: PropTypes.func,
|
|
|
|
}
|