Browse Source

fix(i18n): parse fiat amounts to number type

We need to pass a number to `<FormattedNumber>` for it to properly
display the currency values. In some cases we were passing a
pre-formatted string which was causing some currency amount to render
as NaN.
renovate/lint-staged-8.x
Tom Kirkpatrick 6 years ago
parent
commit
a0e77b1e1f
No known key found for this signature in database GPG Key ID: 72203A8EC5967EA8
  1. 11
      app/lib/utils/btc.js

11
app/lib/utils/btc.js

@ -2,12 +2,6 @@
import sb from 'satoshi-bitcoin'
////////////////
// Helpers /////
////////////////
const numberWithCommas = x => x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
//////////////////////
// BTC to things /////
/////////////////////
@ -24,8 +18,9 @@ export function btcToBits(btc) {
}
export function btcToFiat(btc, price) {
const amount = parseFloat(btc * price).toFixed(2)
return btc > 0 && amount <= 0 ? '< 0.01' : numberWithCommas(amount)
if (btc === undefined || btc === null || btc === '') return null
return parseFloat(btc * price)
}
////////////////////////////

Loading…
Cancel
Save