2016-08-13 00:41:59 +02:00
|
|
|
const Component = require('react').Component
|
|
|
|
const h = require('react-hyperscript')
|
|
|
|
const inherits = require('util').inherits
|
|
|
|
const connect = require('react-redux').connect
|
|
|
|
const CopyButton = require('./copyButton')
|
|
|
|
|
|
|
|
module.exports = connect(mapStateToProps)(QrCodeView)
|
|
|
|
|
|
|
|
function mapStateToProps (state) {
|
|
|
|
return {
|
|
|
|
Qr: state.appState.Qr,
|
|
|
|
buyView: state.appState.buyView,
|
2016-08-18 19:40:35 +02:00
|
|
|
warning: state.appState.warning,
|
2016-08-13 00:41:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inherits(QrCodeView, Component)
|
|
|
|
|
|
|
|
function QrCodeView () {
|
|
|
|
Component.call(this)
|
|
|
|
}
|
|
|
|
|
|
|
|
QrCodeView.prototype.render = function () {
|
|
|
|
var props = this.props
|
|
|
|
var Qr = props.Qr
|
|
|
|
return h('.main-container.flex-column', {
|
2016-08-18 19:40:35 +02:00
|
|
|
key: 'qr',
|
2016-08-13 00:41:59 +02:00
|
|
|
style: {
|
|
|
|
justifyContent: 'center',
|
|
|
|
padding: '45px',
|
|
|
|
alignItems: 'center',
|
|
|
|
},
|
|
|
|
}, [
|
2016-08-13 02:43:24 +02:00
|
|
|
Array.isArray(Qr.message) ? h('.message-container', this.renderMultiMessage()) : h('h3', Qr.message),
|
2016-08-18 19:40:35 +02:00
|
|
|
|
|
|
|
this.props.warning ? this.props.warning && h('span.error.flex-center', {
|
|
|
|
style: {
|
|
|
|
textAlign: 'center',
|
|
|
|
width: '229px',
|
|
|
|
height: '82px',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
this.props.warning) : null,
|
|
|
|
|
2016-08-13 00:41:59 +02:00
|
|
|
h('#qr-container.flex-column', {
|
|
|
|
style: {
|
|
|
|
marginTop: '25px',
|
|
|
|
marginBottom: '15px',
|
|
|
|
},
|
|
|
|
dangerouslySetInnerHTML: {
|
|
|
|
__html: Qr.image,
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
h('.flex-row', [
|
2016-08-15 06:41:08 +02:00
|
|
|
h('h3.ellip-address', {
|
|
|
|
style: {
|
|
|
|
width: '247px',
|
|
|
|
},
|
|
|
|
}, Qr.data),
|
2016-08-13 00:41:59 +02:00
|
|
|
h(CopyButton, {
|
|
|
|
value: Qr.data,
|
|
|
|
}),
|
|
|
|
]),
|
|
|
|
])
|
|
|
|
}
|
2016-08-13 02:43:24 +02:00
|
|
|
|
|
|
|
QrCodeView.prototype.renderMultiMessage = function () {
|
|
|
|
var Qr = this.props.Qr
|
|
|
|
var multiMessage = Qr.message.map((message) => h('.qr-message', message))
|
|
|
|
return multiMessage
|
|
|
|
}
|