aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/sender-to-recipient.js
blob: 6b9cd32ea3a44cadab5b8c3a883d977d833294a2 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const { Component } = require('react')
const h = require('react-hyperscript')
const connect = require('react-redux').connect
const PropTypes = require('prop-types')
const Identicon = require('./identicon')

class SenderToRecipient extends Component {
  renderRecipientIcon () {
    const { recipientAddress } = this.props
    return (
      recipientAddress
        ? h(Identicon, { address: recipientAddress, diameter: 20 })
        : h('i.fa.fa-file-text-o')
    )
  }

  renderRecipient () {
    const { recipientName } = this.props
    return (
      h('.sender-to-recipient__recipient', [
        this.renderRecipientIcon(),
        h(
          '.sender-to-recipient__name.sender-to-recipient__recipient-name',
          recipientName || this.context.t('newContract')
        ),
      ])
    )
  }

  render () {
    const { senderName, senderAddress } = this.props

    return (
      h('.sender-to-recipient__container', [
        h('.sender-to-recipient__sender', [
          h('.sender-to-recipient__sender-icon', [
            h(Identicon, {
              address: senderAddress,
              diameter: 20,
            }),
          ]),
          h('.sender-to-recipient__name.sender-to-recipient__sender-name', senderName),
        ]),
        h('.sender-to-recipient__arrow-container', [
          h('.sender-to-recipient__arrow-circle', [
            h('img', {
              height: 15,
              width: 15,
              src: '/images/arrow-right.svg',
            }),
          ]),
        ]),
        this.renderRecipient(),
      ])
    )
  }
}

SenderToRecipient.propTypes = {
  senderName: PropTypes.string,
  senderAddress: PropTypes.string,
  recipientName: PropTypes.string,
  recipientAddress: PropTypes.string,
  t: PropTypes.func,
}

SenderToRecipient.contextTypes = {
  t: PropTypes.func,
}

module.exports = connect()(SenderToRecipient)