diff options
author | Chi Kei Chan <chikeichan@gmail.com> | 2017-09-06 18:17:49 +0800 |
---|---|---|
committer | Chi Kei Chan <chikeichan@gmail.com> | 2017-09-06 18:17:49 +0800 |
commit | f1fb9e10a06d1811d97f61b6369684979b7ecf70 (patch) | |
tree | 674886d99e6be7ea30b83f8f3811643beb792f07 /ui/app/components/balance-component.js | |
parent | 690ddf5ed75967537aa5513986146c262012832a (diff) | |
download | tangerine-wallet-browser-f1fb9e10a06d1811d97f61b6369684979b7ecf70.tar tangerine-wallet-browser-f1fb9e10a06d1811d97f61b6369684979b7ecf70.tar.gz tangerine-wallet-browser-f1fb9e10a06d1811d97f61b6369684979b7ecf70.tar.bz2 tangerine-wallet-browser-f1fb9e10a06d1811d97f61b6369684979b7ecf70.tar.lz tangerine-wallet-browser-f1fb9e10a06d1811d97f61b6369684979b7ecf70.tar.xz tangerine-wallet-browser-f1fb9e10a06d1811d97f61b6369684979b7ecf70.tar.zst tangerine-wallet-browser-f1fb9e10a06d1811d97f61b6369684979b7ecf70.zip |
Adding Token transaction detail screen
Diffstat (limited to 'ui/app/components/balance-component.js')
-rw-r--r-- | ui/app/components/balance-component.js | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/ui/app/components/balance-component.js b/ui/app/components/balance-component.js index 48efc7b6a..6b997944f 100644 --- a/ui/app/components/balance-component.js +++ b/ui/app/components/balance-component.js @@ -2,13 +2,19 @@ const Component = require('react').Component const connect = require('react-redux').connect const h = require('react-hyperscript') const inherits = require('util').inherits +const TokenBalance = require('./token-balance') const { formatBalance, generateBalanceObject } = require('../util') module.exports = connect(mapStateToProps)(BalanceComponent) function mapStateToProps (state) { + const accounts = state.metamask.accounts + const selectedAddress = state.metamask.selectedAddress || Object.keys(accounts)[0] + const account = accounts[selectedAddress] + return { + account, conversionRate: state.metamask.conversionRate, currentCurrency: state.metamask.currentCurrency, } @@ -21,9 +27,8 @@ function BalanceComponent () { BalanceComponent.prototype.render = function () { const props = this.props - const { balanceValue } = props - const needsParse = 'needsParse' in props ? props.needsParse : true - const formattedBalance = balanceValue ? formatBalance(balanceValue, 6, needsParse) : '...' + // const { balanceValue } = props + const { token } = props return h('div.balance-container', {}, [ @@ -33,13 +38,24 @@ BalanceComponent.prototype.render = function () { style: {}, }), - this.renderBalance(formattedBalance), + token ? this.renderTokenBalance() : this.renderBalance(), ]) } -BalanceComponent.prototype.renderBalance = function (formattedBalance) { +BalanceComponent.prototype.renderTokenBalance = function () { + const { token } = this.props + + return h('div.flex-column.balance-display', [ + h('div.token-amount', [ h(TokenBalance, { token }) ]), + ]) +} + +BalanceComponent.prototype.renderBalance = function () { const props = this.props - const { shorten } = props + const { shorten, account } = props + const balanceValue = account && account.balance + const needsParse = 'needsParse' in props ? props.needsParse : true + const formattedBalance = balanceValue ? formatBalance(balanceValue, 6, needsParse) : '...' const showFiat = 'showFiat' in props ? props.showFiat : true if (formattedBalance === 'None' || formattedBalance === '...') { |