diff options
author | Alexander Tseung <alextsg@gmail.com> | 2018-08-24 07:44:38 +0800 |
---|---|---|
committer | Alexander Tseung <alextsg@gmail.com> | 2018-08-24 07:45:28 +0800 |
commit | 342522c6cf23670f931e69ba822eedfd2d6ee252 (patch) | |
tree | 7aac360f85308b3022d6f673a5c572385854e690 /ui/app/components/balance-component.js | |
parent | 2d76ee754b1dd2473d744ce2dba2a3501c9a149c (diff) | |
download | tangerine-wallet-browser-342522c6cf23670f931e69ba822eedfd2d6ee252.tar tangerine-wallet-browser-342522c6cf23670f931e69ba822eedfd2d6ee252.tar.gz tangerine-wallet-browser-342522c6cf23670f931e69ba822eedfd2d6ee252.tar.bz2 tangerine-wallet-browser-342522c6cf23670f931e69ba822eedfd2d6ee252.tar.lz tangerine-wallet-browser-342522c6cf23670f931e69ba822eedfd2d6ee252.tar.xz tangerine-wallet-browser-342522c6cf23670f931e69ba822eedfd2d6ee252.tar.zst tangerine-wallet-browser-342522c6cf23670f931e69ba822eedfd2d6ee252.zip |
Fix naming, add eth.getCode check for actions, fix translations for statuses
Diffstat (limited to 'ui/app/components/balance-component.js')
-rw-r--r-- | ui/app/components/balance-component.js | 35 |
1 files changed, 4 insertions, 31 deletions
diff --git a/ui/app/components/balance-component.js b/ui/app/components/balance-component.js index e31552f2d..329d8b8e9 100644 --- a/ui/app/components/balance-component.js +++ b/ui/app/components/balance-component.js @@ -4,8 +4,7 @@ const h = require('react-hyperscript') const inherits = require('util').inherits const TokenBalance = require('./token-balance') const Identicon = require('./identicon') -const currencyFormatter = require('currency-formatter') -const currencies = require('currency-formatter/currencies') +import CurrencyDisplay from './currency-display' const { formatBalance, generateBalanceObject } = require('../util') @@ -80,38 +79,12 @@ BalanceComponent.prototype.renderBalance = function () { style: {}, }, this.getTokenBalance(formattedBalance, shorten)), - showFiat ? this.renderFiatValue(formattedBalance) : null, + showFiat && h(CurrencyDisplay, { + value: balanceValue, + }), ]) } -BalanceComponent.prototype.renderFiatValue = function (formattedBalance) { - - const { conversionRate, currentCurrency } = this.props - - const fiatDisplayNumber = this.getFiatDisplayNumber(formattedBalance, conversionRate) - - const fiatPrefix = currentCurrency === 'USD' ? '$' : '' - - return this.renderFiatAmount(fiatDisplayNumber, currentCurrency, fiatPrefix) -} - -BalanceComponent.prototype.renderFiatAmount = function (fiatDisplayNumber, fiatSuffix, fiatPrefix) { - const shouldNotRenderFiat = fiatDisplayNumber === 'N/A' || Number(fiatDisplayNumber) === 0 - if (shouldNotRenderFiat) return null - - const upperCaseFiatSuffix = fiatSuffix.toUpperCase() - - const display = currencies.find(currency => currency.code === upperCaseFiatSuffix) - ? currencyFormatter.format(Number(fiatDisplayNumber), { - code: upperCaseFiatSuffix, - }) - : `${fiatPrefix}${fiatDisplayNumber} ${upperCaseFiatSuffix}` - - return h('div.fiat-amount', { - style: {}, - }, display) -} - BalanceComponent.prototype.getTokenBalance = function (formattedBalance, shorten) { const balanceObj = generateBalanceObject(formattedBalance, shorten ? 1 : 3) |