diff options
author | Sara Reynolds <sarareynolds@Saras-MacBook-Pro-2.local> | 2018-07-17 04:02:12 +0800 |
---|---|---|
committer | Sara Reynolds <sarareynolds@Saras-MacBook-Pro-2.local> | 2018-07-17 04:03:24 +0800 |
commit | 684fc710ee6db33e3ca4e5c5777874e46ccef3b1 (patch) | |
tree | ae7770858f6eb00c3694b485c8ca896aec09c05b /ui/app | |
parent | 4014b279d7f02dcf90a289d7ef5d3cd27d953ee4 (diff) | |
download | tangerine-wallet-browser-684fc710ee6db33e3ca4e5c5777874e46ccef3b1.tar.gz tangerine-wallet-browser-684fc710ee6db33e3ca4e5c5777874e46ccef3b1.tar.zst tangerine-wallet-browser-684fc710ee6db33e3ca4e5c5777874e46ccef3b1.zip |
Fix edge cases and add translation compatibility
Diffstat (limited to 'ui/app')
-rw-r--r-- | ui/app/components/send/currency-display/currency-display.js | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/ui/app/components/send/currency-display/currency-display.js b/ui/app/components/send/currency-display/currency-display.js index 12ddc3d53..3bef25e29 100644 --- a/ui/app/components/send/currency-display/currency-display.js +++ b/ui/app/components/send/currency-display/currency-display.js @@ -6,6 +6,11 @@ const { removeLeadingZeroes } = require('../send.utils') const currencyFormatter = require('currency-formatter') const currencies = require('currency-formatter/currencies') const ethUtil = require('ethereumjs-util') +const PropTypes = require('prop-types') + +CurrencyDisplay.contextTypes = { + t: PropTypes.func, +} module.exports = CurrencyDisplay @@ -75,11 +80,13 @@ CurrencyDisplay.prototype.getValueToRender = function ({ selectedToken, conversi CurrencyDisplay.prototype.getConvertedValueToRender = function (nonFormattedValue) { const { primaryCurrency, convertedCurrency, conversionRate } = this.props - if (conversionRate == 0 || conversionRate == null || converstionRate == undefined && nonFormattedValue != 0) { - return null + if (conversionRate == 0 || conversionRate == null || conversionRate == undefined) { + if (nonFormattedValue != 0) { + return null + } } - let convertedValue = conversionUtil(nonFormattedValue, { + const convertedValue = conversionUtil(nonFormattedValue, { fromNumericBase: 'dec', fromCurrency: primaryCurrency, toCurrency: convertedCurrency, @@ -109,15 +116,14 @@ CurrencyDisplay.prototype.getInputWidth = function (valueToRender, readOnly) { } CurrencyDisplay.prototype.onlyRenderConversions = function (convertedValueToRender) { - const{ + const { convertedBalanceClassName = 'currency-display__converted-value', convertedCurrency, } = this.props - return h('div', { className: convertedBalanceClassName, }, convertedValueToRender == null - ? 'No Conversion Rate' + ? this.context.t('noConversionRateAvailable') : `${convertedValueToRender} ${convertedCurrency.toUpperCase()}` ) } |