2017-08-21 04:28:20 +02:00
|
|
|
const Component = require('react').Component
|
|
|
|
const h = require('react-hyperscript')
|
|
|
|
const inherits = require('util').inherits
|
|
|
|
const connect = require('react-redux').connect
|
|
|
|
const actions = require('../../actions')
|
|
|
|
|
|
|
|
function mapStateToProps (state) {
|
|
|
|
return {
|
|
|
|
network: state.metamask.network,
|
|
|
|
address: state.metamask.selectedAddress,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function mapDispatchToProps (dispatch) {
|
|
|
|
return {
|
|
|
|
toCoinbase: (address) => {
|
|
|
|
dispatch(actions.buyEth({ network: '1', address, amount: 0 }))
|
|
|
|
},
|
|
|
|
hideModal: () => {
|
|
|
|
dispatch(actions.hideModal())
|
2017-08-21 21:53:15 +02:00
|
|
|
},
|
2017-09-22 23:00:00 +02:00
|
|
|
createAccount: (newAccountName) => {
|
|
|
|
dispatch(actions.addNewAccount())
|
2017-09-22 08:59:27 +02:00
|
|
|
.then((newAccountAddress) => {
|
2017-09-22 23:00:00 +02:00
|
|
|
if (newAccountName) {
|
|
|
|
dispatch(actions.saveAccountLabel(newAccountAddress, newAccountName))
|
|
|
|
}
|
2017-09-22 08:59:27 +02:00
|
|
|
dispatch(actions.hideModal())
|
|
|
|
})
|
2017-09-15 17:09:34 +02:00
|
|
|
},
|
2017-10-25 23:36:12 +02:00
|
|
|
showImportPage: () => dispatch(actions.showImportPage()),
|
2017-08-21 04:28:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-21 15:14:28 +02:00
|
|
|
inherits(NewAccountModal, Component)
|
|
|
|
function NewAccountModal () {
|
2017-08-21 04:28:20 +02:00
|
|
|
Component.call(this)
|
2017-09-22 08:59:27 +02:00
|
|
|
|
|
|
|
this.state = {
|
2017-10-25 23:36:12 +02:00
|
|
|
newAccountName: '',
|
2017-09-22 08:59:27 +02:00
|
|
|
}
|
2017-08-21 04:28:20 +02:00
|
|
|
}
|
|
|
|
|
2017-08-21 15:14:28 +02:00
|
|
|
module.exports = connect(mapStateToProps, mapDispatchToProps)(NewAccountModal)
|
2017-08-21 04:28:20 +02:00
|
|
|
|
2017-08-21 15:14:28 +02:00
|
|
|
NewAccountModal.prototype.render = function () {
|
2017-09-22 08:59:27 +02:00
|
|
|
const { newAccountName } = this.state
|
|
|
|
|
2017-08-21 04:28:20 +02:00
|
|
|
return h('div', {}, [
|
2017-08-21 15:14:28 +02:00
|
|
|
h('div.new-account-modal-wrapper', {
|
2017-08-21 04:28:20 +02:00
|
|
|
}, [
|
2017-08-25 02:31:01 +02:00
|
|
|
h('div.new-account-modal-header', {}, [
|
2017-08-21 15:14:28 +02:00
|
|
|
'New Account',
|
2017-08-21 04:28:20 +02:00
|
|
|
]),
|
|
|
|
|
2017-09-06 19:10:27 +02:00
|
|
|
h('div.modal-close-x', {
|
|
|
|
onClick: this.props.hideModal,
|
|
|
|
}),
|
2017-08-29 16:50:48 +02:00
|
|
|
|
2017-08-25 02:31:01 +02:00
|
|
|
h('div.new-account-modal-content', {}, [
|
2017-08-21 15:14:28 +02:00
|
|
|
'Account Name',
|
|
|
|
]),
|
2017-08-21 04:28:20 +02:00
|
|
|
|
2017-08-25 02:31:01 +02:00
|
|
|
h('div.new-account-input-wrapper', {}, [
|
|
|
|
h('input.new-account-input', {
|
2017-08-29 16:50:48 +02:00
|
|
|
placeholder: 'E.g. My new account',
|
2017-10-25 23:36:12 +02:00
|
|
|
onChange: event => this.setState({ newAccountName: event.target.value }),
|
2017-08-21 15:14:28 +02:00
|
|
|
}, []),
|
|
|
|
]),
|
2017-08-21 04:28:20 +02:00
|
|
|
|
2017-09-06 19:08:05 +02:00
|
|
|
h('div.new-account-modal-content.after-input', {}, [
|
2017-08-21 15:14:28 +02:00
|
|
|
'or',
|
|
|
|
]),
|
2017-08-21 04:28:20 +02:00
|
|
|
|
2017-10-25 23:36:12 +02:00
|
|
|
h('div.new-account-modal-content.after-input.pointer', {
|
|
|
|
onClick: () => {
|
|
|
|
this.props.hideModal()
|
|
|
|
this.props.showImportPage()
|
|
|
|
},
|
|
|
|
}, 'Import an account'),
|
2017-08-21 04:28:20 +02:00
|
|
|
|
2017-08-25 02:31:01 +02:00
|
|
|
h('div.new-account-modal-content.button', {}, [
|
2017-09-15 17:09:34 +02:00
|
|
|
h('button.btn-clear', {
|
2017-10-25 23:36:12 +02:00
|
|
|
onClick: () => this.props.createAccount(newAccountName),
|
2017-09-15 17:09:34 +02:00
|
|
|
}, [
|
2017-08-21 15:14:28 +02:00
|
|
|
'SAVE',
|
|
|
|
]),
|
|
|
|
]),
|
2017-08-29 16:50:48 +02:00
|
|
|
]),
|
2017-08-21 04:28:20 +02:00
|
|
|
])
|
|
|
|
}
|