You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
3.0 KiB
109 lines
3.0 KiB
7 years ago
|
import React, { Component } from 'react'
|
||
|
import PropTypes from 'prop-types'
|
||
6 years ago
|
import classnames from 'classnames'
|
||
6 years ago
|
import { checksumAddress } from '../../../helpers/utils/util'
|
||
|
import Identicon from '../../../components/ui/identicon'
|
||
|
import UserPreferencedCurrencyDisplay from '../../../components/app/user-preferenced-currency-display'
|
||
|
import { PRIMARY, SECONDARY } from '../../../helpers/constants/common'
|
||
|
import Tooltip from '../../../components/ui/tooltip-v2'
|
||
7 years ago
|
|
||
|
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,
|
||
6 years ago
|
balanceIsCached: PropTypes.bool,
|
||
6 years ago
|
showFiat: PropTypes.bool,
|
||
7 years ago
|
};
|
||
|
|
||
6 years ago
|
static defaultProps = {
|
||
|
showFiat: true,
|
||
|
}
|
||
|
|
||
6 years ago
|
static contextTypes = {
|
||
|
t: PropTypes.func,
|
||
|
};
|
||
|
|
||
7 years ago
|
render () {
|
||
|
const {
|
||
|
account,
|
||
7 years ago
|
className,
|
||
7 years ago
|
displayAddress = false,
|
||
7 years ago
|
displayBalance = true,
|
||
|
handleClick,
|
||
|
icon = null,
|
||
6 years ago
|
balanceIsCached,
|
||
6 years ago
|
showFiat,
|
||
7 years ago
|
} = this.props
|
||
|
|
||
|
const { name, address, balance } = account || {}
|
||
|
|
||
|
return (<div
|
||
|
className={`account-list-item ${className}`}
|
||
6 years ago
|
onClick={() => handleClick && handleClick({ name, address, balance })}
|
||
7 years ago
|
>
|
||
|
|
||
7 years ago
|
<div className="account-list-item__top-row">
|
||
7 years ago
|
<Identicon
|
||
|
address={address}
|
||
7 years ago
|
className="account-list-item__identicon"
|
||
7 years ago
|
diameter={18}
|
||
|
/>
|
||
|
|
||
7 years ago
|
<div className="account-list-item__account-name">{ name || address }</div>
|
||
7 years ago
|
|
||
7 years ago
|
{icon && <div className="account-list-item__icon">{ icon }</div>}
|
||
7 years ago
|
|
||
|
</div>
|
||
|
|
||
7 years ago
|
{displayAddress && name && <div className="account-list-item__account-address">
|
||
7 years ago
|
{ checksumAddress(address) }
|
||
|
</div>}
|
||
|
|
||
6 years ago
|
{
|
||
|
displayBalance && (
|
||
6 years ago
|
<Tooltip
|
||
|
position="left"
|
||
|
title={this.context.t('balanceOutdated')}
|
||
|
disabled={!balanceIsCached}
|
||
|
style={{
|
||
|
left: '-20px !important',
|
||
|
}}
|
||
|
>
|
||
|
<div className={classnames('account-list-item__account-balances', {
|
||
|
'account-list-item__cached-balances': balanceIsCached,
|
||
|
})}>
|
||
|
<div className="account-list-item__primary-cached-container">
|
||
|
<UserPreferencedCurrencyDisplay
|
||
|
type={PRIMARY}
|
||
|
value={balance}
|
||
|
hideTitle={true}
|
||
|
/>
|
||
|
{
|
||
|
balanceIsCached ? <span className="account-list-item__cached-star">*</span> : null
|
||
|
}
|
||
|
</div>
|
||
6 years ago
|
{
|
||
|
showFiat && (
|
||
|
<UserPreferencedCurrencyDisplay
|
||
|
type={SECONDARY}
|
||
|
value={balance}
|
||
|
hideTitle={true}
|
||
|
/>
|
||
|
)
|
||
|
}
|
||
6 years ago
|
</div>
|
||
|
</Tooltip>
|
||
6 years ago
|
)
|
||
|
}
|
||
7 years ago
|
|
||
|
</div>)
|
||
|
}
|
||
|
}
|