2018-02-01 03:08:49 +01:00
|
|
|
const Component = require('react').Component
|
|
|
|
const { Switch, Route, matchPath } = require('react-router-dom')
|
|
|
|
const PropTypes = require('prop-types')
|
|
|
|
const h = require('react-hyperscript')
|
|
|
|
const connect = require('react-redux').connect
|
|
|
|
const actions = require('../../../actions')
|
|
|
|
const { getCurrentViewContext } = require('../../../selectors')
|
|
|
|
const classnames = require('classnames')
|
|
|
|
const NewAccountCreateForm = require('./new-account')
|
|
|
|
const NewAccountImportForm = require('./import-account')
|
|
|
|
const { NEW_ACCOUNT_ROUTE, IMPORT_ACCOUNT_ROUTE } = require('../../../routes')
|
|
|
|
|
|
|
|
class CreateAccountPage extends Component {
|
|
|
|
renderTabs () {
|
|
|
|
const { history, location } = this.props
|
|
|
|
|
|
|
|
return h('div.new-account__tabs', [
|
|
|
|
h('div.new-account__tabs__tab', {
|
|
|
|
className: classnames('new-account__tabs__tab', {
|
|
|
|
'new-account__tabs__selected': matchPath(location.pathname, {
|
|
|
|
path: NEW_ACCOUNT_ROUTE, exact: true,
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
onClick: () => history.push(NEW_ACCOUNT_ROUTE),
|
2018-06-06 20:38:57 +02:00
|
|
|
}, [
|
|
|
|
this.context.t('create'),
|
|
|
|
]),
|
2018-02-01 03:08:49 +01:00
|
|
|
|
|
|
|
h('div.new-account__tabs__tab', {
|
|
|
|
className: classnames('new-account__tabs__tab', {
|
|
|
|
'new-account__tabs__selected': matchPath(location.pathname, {
|
|
|
|
path: IMPORT_ACCOUNT_ROUTE, exact: true,
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
onClick: () => history.push(IMPORT_ACCOUNT_ROUTE),
|
2018-06-06 20:38:57 +02:00
|
|
|
}, [
|
|
|
|
this.context.t('import'),
|
|
|
|
]),
|
2018-02-01 03:08:49 +01:00
|
|
|
])
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
return h('div.new-account', {}, [
|
|
|
|
h('div.new-account__header', [
|
2018-07-03 00:49:33 +02:00
|
|
|
h('div.new-account__title', this.context.t('newAccount')),
|
2018-02-01 03:08:49 +01:00
|
|
|
this.renderTabs(),
|
|
|
|
]),
|
|
|
|
h('div.new-account__form', [
|
|
|
|
h(Switch, [
|
|
|
|
h(Route, {
|
|
|
|
exact: true,
|
|
|
|
path: NEW_ACCOUNT_ROUTE,
|
|
|
|
component: NewAccountCreateForm,
|
|
|
|
}),
|
|
|
|
h(Route, {
|
|
|
|
exact: true,
|
|
|
|
path: IMPORT_ACCOUNT_ROUTE,
|
|
|
|
component: NewAccountImportForm,
|
|
|
|
}),
|
|
|
|
]),
|
|
|
|
]),
|
|
|
|
])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CreateAccountPage.propTypes = {
|
|
|
|
location: PropTypes.object,
|
|
|
|
history: PropTypes.object,
|
2018-06-06 20:38:57 +02:00
|
|
|
t: PropTypes.func,
|
|
|
|
}
|
|
|
|
|
|
|
|
CreateAccountPage.contextTypes = {
|
|
|
|
t: PropTypes.func,
|
2018-02-01 03:08:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const mapStateToProps = state => ({
|
|
|
|
displayedForm: getCurrentViewContext(state),
|
|
|
|
})
|
|
|
|
|
|
|
|
const mapDispatchToProps = dispatch => ({
|
|
|
|
displayForm: form => dispatch(actions.setNewAccountForm(form)),
|
|
|
|
showQrView: (selected, identity) => dispatch(actions.showQrView(selected, identity)),
|
|
|
|
showExportPrivateKeyModal: () => {
|
|
|
|
dispatch(actions.showModal({ name: 'EXPORT_PRIVATE_KEY' }))
|
|
|
|
},
|
|
|
|
hideModal: () => dispatch(actions.hideModal()),
|
2018-04-19 05:33:51 +02:00
|
|
|
setAccountLabel: (address, label) => dispatch(actions.setAccountLabel(address, label)),
|
2018-02-01 03:08:49 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
module.exports = connect(mapStateToProps, mapDispatchToProps)(CreateAccountPage)
|