2018-01-10 19:25:38 +01:00
|
|
|
const Component = require('react').Component
|
|
|
|
const h = require('react-hyperscript')
|
2018-03-29 17:00:44 +02:00
|
|
|
const PropTypes = require('prop-types')
|
2018-01-10 19:25:38 +01:00
|
|
|
const inherits = require('util').inherits
|
2018-03-29 17:00:44 +02:00
|
|
|
const connect = require('react-redux').connect
|
2018-01-10 19:25:38 +01:00
|
|
|
const actions = require('../../actions')
|
|
|
|
const { getCurrentViewContext } = require('../../selectors')
|
|
|
|
const classnames = require('classnames')
|
|
|
|
|
|
|
|
const NewAccountCreateForm = require('./create-form')
|
|
|
|
const NewAccountImportForm = require('../import')
|
|
|
|
|
|
|
|
function mapStateToProps (state) {
|
|
|
|
return {
|
|
|
|
displayedForm: getCurrentViewContext(state),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function mapDispatchToProps (dispatch) {
|
|
|
|
return {
|
|
|
|
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()),
|
|
|
|
saveAccountLabel: (address, label) => dispatch(actions.saveAccountLabel(address, label)),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inherits(AccountDetailsModal, Component)
|
|
|
|
function AccountDetailsModal (props) {
|
|
|
|
Component.call(this)
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
displayedForm: props.displayedForm,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-29 17:00:44 +02:00
|
|
|
AccountDetailsModal.contextTypes = {
|
|
|
|
t: PropTypes.func,
|
|
|
|
}
|
|
|
|
|
2018-01-10 19:25:38 +01:00
|
|
|
module.exports = connect(mapStateToProps, mapDispatchToProps)(AccountDetailsModal)
|
|
|
|
|
2018-03-29 17:00:44 +02:00
|
|
|
|
2018-01-10 19:25:38 +01:00
|
|
|
AccountDetailsModal.prototype.render = function () {
|
|
|
|
const { displayedForm, displayForm } = this.props
|
|
|
|
|
|
|
|
return h('div.new-account', {}, [
|
2018-01-24 09:14:47 +01:00
|
|
|
|
2018-01-10 19:25:38 +01:00
|
|
|
h('div.new-account__header', [
|
|
|
|
|
2018-03-29 17:00:44 +02:00
|
|
|
h('div.new-account__title', this.context.t('newAccount')),
|
2018-01-10 19:25:38 +01:00
|
|
|
|
|
|
|
h('div.new-account__tabs', [
|
|
|
|
|
|
|
|
h('div.new-account__tabs__tab', {
|
|
|
|
className: classnames('new-account__tabs__tab', {
|
|
|
|
'new-account__tabs__selected': displayedForm === 'CREATE',
|
|
|
|
'new-account__tabs__unselected cursor-pointer': displayedForm !== 'CREATE',
|
|
|
|
}),
|
|
|
|
onClick: () => displayForm('CREATE'),
|
2018-03-29 17:00:44 +02:00
|
|
|
}, this.context.t('createDen')),
|
2018-01-10 19:25:38 +01:00
|
|
|
|
|
|
|
h('div.new-account__tabs__tab', {
|
|
|
|
className: classnames('new-account__tabs__tab', {
|
|
|
|
'new-account__tabs__selected': displayedForm === 'IMPORT',
|
|
|
|
'new-account__tabs__unselected cursor-pointer': displayedForm !== 'IMPORT',
|
|
|
|
}),
|
|
|
|
onClick: () => displayForm('IMPORT'),
|
2018-03-29 17:00:44 +02:00
|
|
|
}, this.context.t('import')),
|
2018-01-10 19:25:38 +01:00
|
|
|
|
|
|
|
]),
|
|
|
|
|
|
|
|
]),
|
|
|
|
|
|
|
|
h('div.new-account__form', [
|
|
|
|
|
|
|
|
displayedForm === 'CREATE'
|
|
|
|
? h(NewAccountCreateForm)
|
|
|
|
: h(NewAccountImportForm),
|
|
|
|
|
|
|
|
]),
|
|
|
|
|
|
|
|
])
|
|
|
|
}
|