aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/qr-code.js
blob: 1c744b23412f5de8e0fc2ffa42db51825bb223d1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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,
  }
}

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', {
    style: {
      justifyContent: 'center',
      padding: '45px',
      alignItems: 'center',
    },
  }, [
    Array.isArray(Qr.message) ? h('.message-container', this.renderMultiMessage()) : h('h3', Qr.message),
    h('#qr-container.flex-column', {
      key: 'qr',
      style: {
        marginTop: '25px',
        marginBottom: '15px',
      },
      dangerouslySetInnerHTML: {
        __html: Qr.image,
      },
    }),
    h('.flex-row', [
      h('h3.ellip-address', Qr.data),
      h(CopyButton, {
        value: Qr.data,
      }),
    ]),
  ])
}

QrCodeView.prototype.renderMultiMessage = function () {
  var Qr = this.props.Qr
  var multiMessage = Qr.message.map((message) => h('.qr-message', message))
  return multiMessage
}