2017-10-10 01:17:52 +02:00
|
|
|
const Component = require('react').Component
|
|
|
|
const h = require('react-hyperscript')
|
|
|
|
const inherits = require('util').inherits
|
2018-03-29 17:00:44 +02:00
|
|
|
const connect = require('react-redux').connect
|
2017-10-10 01:17:52 +02:00
|
|
|
const Identicon = require('../identicon')
|
2017-10-13 22:19:22 +02:00
|
|
|
const CurrencyDisplay = require('./currency-display')
|
2017-10-19 04:09:26 +02:00
|
|
|
const { conversionRateSelector, getCurrentCurrency } = require('../../selectors')
|
2017-10-10 01:17:52 +02:00
|
|
|
|
|
|
|
inherits(AccountListItem, Component)
|
|
|
|
function AccountListItem () {
|
|
|
|
Component.call(this)
|
|
|
|
}
|
|
|
|
|
2017-10-19 23:08:52 +02:00
|
|
|
function mapStateToProps (state) {
|
2017-10-13 22:19:22 +02:00
|
|
|
return {
|
2017-10-19 04:09:26 +02:00
|
|
|
conversionRate: conversionRateSelector(state),
|
|
|
|
currentCurrency: getCurrentCurrency(state),
|
2017-10-13 22:19:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = connect(mapStateToProps)(AccountListItem)
|
2017-10-10 01:17:52 +02:00
|
|
|
|
|
|
|
AccountListItem.prototype.render = function () {
|
|
|
|
const {
|
2017-11-10 20:45:43 +01:00
|
|
|
className,
|
2017-10-19 23:08:52 +02:00
|
|
|
account,
|
|
|
|
handleClick,
|
2017-10-10 01:17:52 +02:00
|
|
|
icon = null,
|
2017-10-13 22:19:22 +02:00
|
|
|
conversionRate,
|
2017-10-19 04:09:26 +02:00
|
|
|
currentCurrency,
|
2017-10-23 18:24:47 +02:00
|
|
|
displayBalance = true,
|
|
|
|
displayAddress = false,
|
2017-10-10 01:17:52 +02:00
|
|
|
} = this.props
|
|
|
|
|
2017-10-19 23:08:52 +02:00
|
|
|
const { name, address, balance } = account || {}
|
2017-10-10 01:17:52 +02:00
|
|
|
|
|
|
|
return h('div.account-list-item', {
|
2017-11-10 20:45:43 +01:00
|
|
|
className,
|
2017-10-13 22:19:22 +02:00
|
|
|
onClick: () => handleClick({ name, address, balance }),
|
2017-10-10 01:17:52 +02:00
|
|
|
}, [
|
|
|
|
|
|
|
|
h('div.account-list-item__top-row', {}, [
|
|
|
|
|
|
|
|
h(
|
|
|
|
Identicon,
|
|
|
|
{
|
|
|
|
address,
|
|
|
|
diameter: 18,
|
|
|
|
className: 'account-list-item__identicon',
|
|
|
|
},
|
2017-10-13 22:19:22 +02:00
|
|
|
),
|
2017-10-10 01:17:52 +02:00
|
|
|
|
2017-10-23 18:24:47 +02:00
|
|
|
h('div.account-list-item__account-name', {}, name || address),
|
2017-10-10 01:17:52 +02:00
|
|
|
|
|
|
|
icon && h('div.account-list-item__icon', [icon]),
|
|
|
|
|
|
|
|
]),
|
|
|
|
|
2017-10-23 18:24:47 +02:00
|
|
|
displayAddress && name && h('div.account-list-item__account-address', address),
|
|
|
|
|
|
|
|
displayBalance && h(CurrencyDisplay, {
|
2017-10-13 22:19:22 +02:00
|
|
|
primaryCurrency: 'ETH',
|
2017-10-19 04:09:26 +02:00
|
|
|
convertedCurrency: currentCurrency,
|
2017-10-13 22:19:22 +02:00
|
|
|
value: balance,
|
|
|
|
conversionRate,
|
|
|
|
readOnly: true,
|
|
|
|
className: 'account-list-item__account-balances',
|
|
|
|
primaryBalanceClassName: 'account-list-item__account-primary-balance',
|
|
|
|
convertedBalanceClassName: 'account-list-item__account-secondary-balance',
|
|
|
|
}, name),
|
2017-10-10 01:17:52 +02:00
|
|
|
|
|
|
|
])
|
2017-11-02 13:15:59 +01:00
|
|
|
}
|