2016-04-14 00:28:44 +02:00
|
|
|
const inherits = require('util').inherits
|
|
|
|
const Component = require('react').Component
|
|
|
|
const h = require('react-hyperscript')
|
|
|
|
const formatBalance = require('../util').formatBalance
|
2016-06-17 03:37:39 +02:00
|
|
|
const addressSummary = require('../util').addressSummary
|
2016-04-14 00:28:44 +02:00
|
|
|
|
2016-05-06 23:24:01 +02:00
|
|
|
const Panel = require('./panel')
|
|
|
|
|
2016-04-14 00:28:44 +02:00
|
|
|
module.exports = AccountPanel
|
|
|
|
|
|
|
|
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-05-06 23:24:01 +02:00
|
|
|
var panelOpts = {
|
|
|
|
key: `accountPanel${identity.address}`,
|
|
|
|
onClick: (event) => {
|
|
|
|
if (state.onShowDetail) {
|
|
|
|
state.onShowDetail(identity.address, event)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
identiconKey: identity.address,
|
|
|
|
identiconLabel: identity.name,
|
|
|
|
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-05-06 23:24:01 +02:00
|
|
|
return h(Panel, panelOpts,
|
|
|
|
!state.onShowDetail ? null : h('.arrow-right.cursor-pointer', [
|
|
|
|
h('i.fa.fa-chevron-right.fa-lg'),
|
|
|
|
]))
|
2016-04-14 00:28:44 +02:00
|
|
|
}
|
|
|
|
|
2016-06-21 22:18:32 +02:00
|
|
|
function balanceOrFaucetingIndication (account, isFauceting) {
|
2016-04-14 00:28:44 +02:00
|
|
|
// Temporarily deactivating isFauceting indication
|
|
|
|
// because it shows fauceting for empty restored accounts.
|
2016-06-21 22:18:32 +02:00
|
|
|
if (/* isFauceting*/ false) {
|
2016-05-06 23:24:01 +02:00
|
|
|
return {
|
|
|
|
key: 'Account is auto-funding.',
|
|
|
|
value: 'Please wait.',
|
|
|
|
}
|
2016-04-14 00:28:44 +02:00
|
|
|
} else {
|
2016-05-06 23:24:01 +02:00
|
|
|
return {
|
|
|
|
key: 'BALANCE',
|
2016-06-21 22:18:32 +02:00
|
|
|
value: formatBalance(account.balance),
|
2016-05-06 23:24:01 +02:00
|
|
|
}
|
2016-04-14 00:28:44 +02:00
|
|
|
}
|
|
|
|
}
|