2019-11-23 03:18:46 +01:00
|
|
|
import React, { Component } from 'react'
|
2016-04-14 00:28:44 +02:00
|
|
|
const inherits = require('util').inherits
|
2019-03-22 00:03:30 +01:00
|
|
|
import Identicon from '../ui/identicon'
|
|
|
|
const formatBalance = require('../../helpers/utils/util').formatBalance
|
|
|
|
const addressSummary = require('../../helpers/utils/util').addressSummary
|
2016-04-14 00:28:44 +02:00
|
|
|
|
|
|
|
module.exports = AccountPanel
|
|
|
|
|
2016-06-24 01:28:57 +02:00
|
|
|
|
2016-04-14 00:28:44 +02:00
|
|
|
inherits(AccountPanel, Component)
|
2016-06-21 22:18:32 +02:00
|
|
|
function AccountPanel () {
|
2016-04-14 00:28:44 +02:00
|
|
|
Component.call(this)
|
|
|
|
}
|
|
|
|
|
2016-06-21 22:18:32 +02:00
|
|
|
AccountPanel.prototype.render = function () {
|
2016-04-14 00:28:44 +02:00
|
|
|
var state = this.props
|
|
|
|
var identity = state.identity || {}
|
|
|
|
var account = state.account || {}
|
|
|
|
var isFauceting = state.isFauceting
|
|
|
|
|
2016-06-24 01:28:57 +02:00
|
|
|
var panelState = {
|
2016-05-06 23:24:01 +02:00
|
|
|
key: `accountPanel${identity.address}`,
|
|
|
|
identiconKey: identity.address,
|
2016-07-07 02:58:46 +02:00
|
|
|
identiconLabel: identity.name || '',
|
2016-05-06 23:24:01 +02:00
|
|
|
attributes: [
|
|
|
|
{
|
|
|
|
key: 'ADDRESS',
|
2016-06-17 03:37:39 +02:00
|
|
|
value: addressSummary(identity.address),
|
2016-04-14 00:28:44 +02:00
|
|
|
},
|
2016-05-06 23:24:01 +02:00
|
|
|
balanceOrFaucetingIndication(account, isFauceting),
|
2016-06-21 22:18:32 +02:00
|
|
|
],
|
2016-05-06 23:24:01 +02:00
|
|
|
}
|
2016-04-14 00:28:44 +02:00
|
|
|
|
2016-06-24 01:28:57 +02:00
|
|
|
return (
|
2019-11-23 03:18:46 +01:00
|
|
|
<div
|
|
|
|
className="identity-panel flex-row flex-space-between"
|
|
|
|
style={{ flex: '1 0 auto', cursor: panelState.onClick ? 'pointer' : undefined }}
|
|
|
|
onClick={panelState.onClick}
|
|
|
|
>
|
|
|
|
<div className="identicon-wrapper flex-column select-none">
|
|
|
|
<Identicon address={panelState.identiconKey} imageify={state.imageifyIdenticons} />
|
|
|
|
<span className="font-small">{panelState.identiconLabel.substring(0, 7) + '...'}</span>
|
|
|
|
</div>
|
|
|
|
<div className="identity-data flex-column flex-justify-center flex-grow select-none">
|
|
|
|
{panelState.attributes.map((attr) => (
|
|
|
|
<div className="flex-row flex-space-between" key={'' + Math.round(Math.random() * 1000000)}>
|
|
|
|
<label className="font-small no-select">{attr.key}</label>
|
|
|
|
<span className="font-small">{attr.value}</span>
|
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</div>
|
2016-06-24 01:28:57 +02:00
|
|
|
)
|
2016-04-14 00:28:44 +02:00
|
|
|
}
|
|
|
|
|
2019-05-08 21:51:33 +02:00
|
|
|
function balanceOrFaucetingIndication (account) {
|
|
|
|
return {
|
|
|
|
key: 'BALANCE',
|
|
|
|
value: formatBalance(account.balance),
|
2016-04-14 00:28:44 +02:00
|
|
|
}
|
|
|
|
}
|