Browse Source

Merge pull request #792 from mrfelton/fix/i18n-currency-display

fix(i18n): parse fiat amounts to number type
renovate/lint-staged-8.x
JimmyMow 6 years ago
committed by GitHub
parent
commit
3f5d5c459f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  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