nifty-wallet/ui/app/components/coinbase-form.js

69 lines
1.6 KiB
JavaScript
Raw Normal View History

2016-08-10 13:43:01 -07: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')
module.exports = connect(mapStateToProps)(CoinbaseForm)
2016-11-11 10:26:12 -08:00
function mapStateToProps (state) {
2016-08-10 13:43:01 -07:00
return {
warning: state.appState.warning,
}
}
inherits(CoinbaseForm, Component)
2016-11-11 10:26:12 -08:00
function CoinbaseForm () {
2016-08-10 13:43:01 -07:00
Component.call(this)
}
CoinbaseForm.prototype.render = function () {
var props = this.props
return h('.flex-column', {
style: {
// margin: '10px',
padding: '25px',
width: '100%',
2016-08-10 13:43:01 -07:00
},
}, [
h('.flex-row', {
style: {
justifyContent: 'space-around',
margin: '33px',
marginTop: '0px',
2016-08-10 13:43:01 -07:00
},
}, [
h('button', {
onClick: this.toCoinbase.bind(this),
}, 'Continue to Coinbase'),
h('button', {
onClick: () => props.dispatch(actions.backTobuyView(props.accounts.address)),
2016-08-10 13:43:01 -07:00
}, 'Cancel'),
]),
])
}
CoinbaseForm.prototype.handleAmount = function (event) {
this.props.dispatch(actions.updateCoinBaseAmount(event.target.value))
}
CoinbaseForm.prototype.handleAddress = function (event) {
this.props.dispatch(actions.updateBuyAddress(event.target.value))
}
CoinbaseForm.prototype.toCoinbase = function () {
const props = this.props
const address = props.buyView.buyAddress
props.dispatch(actions.buyEth({ network: '1', address, amount: 0 }))
2016-08-10 13:43:01 -07:00
}
CoinbaseForm.prototype.renderLoading = function () {
return h('img', {
style: {
width: '27px',
marginRight: '-27px',
},
src: 'images/loading.svg',
})
}