1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Fix edge cases and add translation compatibility

This commit is contained in:
Sara Reynolds 2018-07-16 13:02:12 -07:00
parent 4014b279d7
commit 684fc710ee
2 changed files with 15 additions and 6 deletions

View File

@ -584,6 +584,9 @@
"noDeposits": { "noDeposits": {
"message": "No deposits received" "message": "No deposits received"
}, },
"noConversionRateAvailable":{
"message": "No Conversion Rate Available"
},
"noTransactionHistory": { "noTransactionHistory": {
"message": "No transaction history." "message": "No transaction history."
}, },

View File

@ -6,6 +6,11 @@ const { removeLeadingZeroes } = require('../send.utils')
const currencyFormatter = require('currency-formatter') const currencyFormatter = require('currency-formatter')
const currencies = require('currency-formatter/currencies') const currencies = require('currency-formatter/currencies')
const ethUtil = require('ethereumjs-util') const ethUtil = require('ethereumjs-util')
const PropTypes = require('prop-types')
CurrencyDisplay.contextTypes = {
t: PropTypes.func,
}
module.exports = CurrencyDisplay module.exports = CurrencyDisplay
@ -75,11 +80,13 @@ CurrencyDisplay.prototype.getValueToRender = function ({ selectedToken, conversi
CurrencyDisplay.prototype.getConvertedValueToRender = function (nonFormattedValue) { CurrencyDisplay.prototype.getConvertedValueToRender = function (nonFormattedValue) {
const { primaryCurrency, convertedCurrency, conversionRate } = this.props const { primaryCurrency, convertedCurrency, conversionRate } = this.props
if (conversionRate == 0 || conversionRate == null || converstionRate == undefined && nonFormattedValue != 0) { if (conversionRate == 0 || conversionRate == null || conversionRate == undefined) {
return null if (nonFormattedValue != 0) {
return null
}
} }
let convertedValue = conversionUtil(nonFormattedValue, { const convertedValue = conversionUtil(nonFormattedValue, {
fromNumericBase: 'dec', fromNumericBase: 'dec',
fromCurrency: primaryCurrency, fromCurrency: primaryCurrency,
toCurrency: convertedCurrency, toCurrency: convertedCurrency,
@ -109,15 +116,14 @@ CurrencyDisplay.prototype.getInputWidth = function (valueToRender, readOnly) {
} }
CurrencyDisplay.prototype.onlyRenderConversions = function (convertedValueToRender) { CurrencyDisplay.prototype.onlyRenderConversions = function (convertedValueToRender) {
const{ const {
convertedBalanceClassName = 'currency-display__converted-value', convertedBalanceClassName = 'currency-display__converted-value',
convertedCurrency, convertedCurrency,
} = this.props } = this.props
return h('div', { return h('div', {
className: convertedBalanceClassName, className: convertedBalanceClassName,
}, convertedValueToRender == null }, convertedValueToRender == null
? 'No Conversion Rate' ? this.context.t('noConversionRateAvailable')
: `${convertedValueToRender} ${convertedCurrency.toUpperCase()}` : `${convertedValueToRender} ${convertedCurrency.toUpperCase()}`
) )
} }