diff options
author | Sara Reynolds <sarareynolds@Saras-MacBook-Pro-2.local> | 2018-07-12 03:00:14 +0800 |
---|---|---|
committer | Sara Reynolds <sarareynolds@Saras-MacBook-Pro-2.local> | 2018-07-17 04:03:23 +0800 |
commit | 8d8de0508ab3cb67870d0c00469ee39f3be06714 (patch) | |
tree | b14d4479e7c5706fa81cc501c33d2a855327273d /ui | |
parent | db4469794e3e843f3cb08222d0a9b568c7816a85 (diff) | |
download | tangerine-wallet-browser-8d8de0508ab3cb67870d0c00469ee39f3be06714.tar tangerine-wallet-browser-8d8de0508ab3cb67870d0c00469ee39f3be06714.tar.gz tangerine-wallet-browser-8d8de0508ab3cb67870d0c00469ee39f3be06714.tar.bz2 tangerine-wallet-browser-8d8de0508ab3cb67870d0c00469ee39f3be06714.tar.lz tangerine-wallet-browser-8d8de0508ab3cb67870d0c00469ee39f3be06714.tar.xz tangerine-wallet-browser-8d8de0508ab3cb67870d0c00469ee39f3be06714.tar.zst tangerine-wallet-browser-8d8de0508ab3cb67870d0c00469ee39f3be06714.zip |
Fixes conversion status for tokens without conversion rates
Diffstat (limited to 'ui')
-rw-r--r-- | ui/app/components/send/currency-display/currency-display.js | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/ui/app/components/send/currency-display/currency-display.js b/ui/app/components/send/currency-display/currency-display.js index 1b9f7738c..70fc9de70 100644 --- a/ui/app/components/send/currency-display/currency-display.js +++ b/ui/app/components/send/currency-display/currency-display.js @@ -82,16 +82,21 @@ CurrencyDisplay.prototype.getConvertedValueToRender = function (nonFormattedValu numberOfDecimals: 2, conversionRate, }) - convertedValue = Number(convertedValue).toFixed(2) - const upperCaseCurrencyCode = convertedCurrency.toUpperCase() - - return currencies.find(currency => currency.code === upperCaseCurrencyCode) - ? currencyFormatter.format(Number(convertedValue), { - code: upperCaseCurrencyCode, - }) - : convertedValue -} + if (conversionRate == 0 && nonFormattedValue != 0) { + convertedValue = null + return convertedValue + } + else { + convertedValue == Number(convertedValue).toFixed(2) + const upperCaseCurrencyCode = convertedCurrency.toUpperCase() + return currencies.find(currency => currency.code === upperCaseCurrencyCode) + ? currencyFormatter.format(Number(convertedValue), { + code: upperCaseCurrencyCode, + }) + : convertedValue + } + } CurrencyDisplay.prototype.handleChange = function (newVal) { this.setState({ valueToRender: removeLeadingZeroes(newVal) }) @@ -105,6 +110,7 @@ CurrencyDisplay.prototype.getInputWidth = function (valueToRender, readOnly) { return (valueLength + decimalPointDeficit + 0.75) + 'ch' } + CurrencyDisplay.prototype.render = function () { const { className = 'currency-display', @@ -121,6 +127,19 @@ CurrencyDisplay.prototype.render = function () { const convertedValueToRender = this.getConvertedValueToRender(valueToRender) + function onlyRenderConversions() { + if (convertedValueToRender == null) { + return h('div', { + className: convertedBalanceClassName, + }, 'No Conversion Rate') + } + else { + return h('div', { + className: convertedBalanceClassName, + }, `${convertedValueToRender} ${convertedCurrency.toUpperCase()}`) + } + } + return h('div', { className, style: { @@ -157,11 +176,7 @@ CurrencyDisplay.prototype.render = function () { ]), - ]), - - h('div', { - className: convertedBalanceClassName, - }, `${convertedValueToRender} ${convertedCurrency.toUpperCase()}`), + ]), onlyRenderConversions(), ]) |