From 8d8de0508ab3cb67870d0c00469ee39f3be06714 Mon Sep 17 00:00:00 2001 From: Sara Reynolds Date: Wed, 11 Jul 2018 15:00:14 -0400 Subject: Fixes conversion status for tokens without conversion rates --- .../send/currency-display/currency-display.js | 43 +++++++++++++++------- 1 file 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(), ]) -- cgit v1.2.3