2018-04-26 18:38:38 +02:00
|
|
|
import React, { Component } from 'react'
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
import { checksumAddress } from '../../../util'
|
|
|
|
import Identicon from '../../identicon'
|
2018-10-17 01:03:29 +02:00
|
|
|
import UserPreferencedCurrencyDisplay from '../../user-preferenced-currency-display'
|
|
|
|
import { PRIMARY, SECONDARY } from '../../../constants/common'
|
2018-04-26 18:38:38 +02:00
|
|
|
|
|
|
|
export default class AccountListItem extends Component {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
account: PropTypes.object,
|
|
|
|
className: PropTypes.string,
|
|
|
|
conversionRate: PropTypes.number,
|
|
|
|
currentCurrency: PropTypes.string,
|
|
|
|
displayAddress: PropTypes.bool,
|
|
|
|
displayBalance: PropTypes.bool,
|
|
|
|
handleClick: PropTypes.func,
|
|
|
|
icon: PropTypes.node,
|
|
|
|
};
|
|
|
|
|
2018-07-02 04:09:28 +02:00
|
|
|
static contextTypes = {
|
|
|
|
t: PropTypes.func,
|
|
|
|
};
|
|
|
|
|
2018-04-26 18:38:38 +02:00
|
|
|
render () {
|
|
|
|
const {
|
|
|
|
account,
|
2018-04-27 02:38:14 +02:00
|
|
|
className,
|
2018-04-26 18:38:38 +02:00
|
|
|
displayAddress = false,
|
2018-04-27 02:38:14 +02:00
|
|
|
displayBalance = true,
|
|
|
|
handleClick,
|
|
|
|
icon = null,
|
2018-04-26 18:38:38 +02:00
|
|
|
} = this.props
|
|
|
|
|
|
|
|
const { name, address, balance } = account || {}
|
|
|
|
|
|
|
|
return (<div
|
|
|
|
className={`account-list-item ${className}`}
|
|
|
|
onClick={() => handleClick({ name, address, balance })}
|
|
|
|
>
|
|
|
|
|
2018-04-27 02:38:14 +02:00
|
|
|
<div className="account-list-item__top-row">
|
2018-04-26 18:38:38 +02:00
|
|
|
<Identicon
|
|
|
|
address={address}
|
2018-04-27 02:38:14 +02:00
|
|
|
className="account-list-item__identicon"
|
2018-04-26 18:38:38 +02:00
|
|
|
diameter={18}
|
|
|
|
/>
|
|
|
|
|
2018-04-27 02:38:14 +02:00
|
|
|
<div className="account-list-item__account-name">{ name || address }</div>
|
2018-04-26 18:38:38 +02:00
|
|
|
|
2018-04-27 02:38:14 +02:00
|
|
|
{icon && <div className="account-list-item__icon">{ icon }</div>}
|
2018-04-26 18:38:38 +02:00
|
|
|
|
|
|
|
</div>
|
|
|
|
|
2018-04-27 02:38:14 +02:00
|
|
|
{displayAddress && name && <div className="account-list-item__account-address">
|
2018-04-26 18:38:38 +02:00
|
|
|
{ checksumAddress(address) }
|
|
|
|
</div>}
|
|
|
|
|
2018-10-17 01:03:29 +02:00
|
|
|
{
|
|
|
|
displayBalance && (
|
|
|
|
<div className="account-list-item__account-balances">
|
|
|
|
<UserPreferencedCurrencyDisplay
|
|
|
|
type={PRIMARY}
|
|
|
|
value={balance}
|
|
|
|
/>
|
|
|
|
<UserPreferencedCurrencyDisplay
|
|
|
|
type={SECONDARY}
|
|
|
|
value={balance}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
2018-04-26 18:38:38 +02:00
|
|
|
|
|
|
|
</div>)
|
|
|
|
}
|
|
|
|
}
|