From a0e77b1e1f20b33ad5434dd5acd7eb1443282000 Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Wed, 19 Sep 2018 18:29:48 +0200 Subject: [PATCH] fix(i18n): parse fiat amounts to number type We need to pass a number to `` 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. --- app/lib/utils/btc.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/app/lib/utils/btc.js b/app/lib/utils/btc.js index 80f913ca..7f635ab0 100644 --- a/app/lib/utils/btc.js +++ b/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) } ////////////////////////////