fix large number in balance view card

pull/2164/head
Ayrat Badykov 6 years ago
parent ed30111638
commit 9080db5717
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 1
      apps/block_scout_web/assets/js/lib/currency.js
  2. 12
      apps/block_scout_web/lib/block_scout_web/views/wei_helpers.ex

@ -18,6 +18,7 @@ function formatCurrencyValue (value, symbol) {
if (value < 0.000001) return `${window.localized['Less than']} ${symbol}0.000001`
if (value < 1) return `${symbol}${numeral(value).format('0.000000')}`
if (value < 100000) return `${symbol}${numeral(value).format('0,0.00')}`
if (value > 1000000000) return `${symbol}${numeral(value).format('0.000e+0')}`
return `${symbol}${numeral(value).format('0,0')}`
}

@ -57,13 +57,19 @@ defmodule BlockScoutWeb.WeiHelpers do
converted_value =
wei
|> Wei.to(unit)
|> Cldr.Number.to_string!(format: "#,##0.##################")
formatted_value =
if converted_value > 1_000_000_000_000 do
Cldr.Number.to_string!(converted_value, format: "0.###E+0")
else
Cldr.Number.to_string!(converted_value, format: "#,##0.##################")
end
if Keyword.get(options, :include_unit_label, true) do
display_unit = display_unit(unit)
"#{converted_value} #{display_unit}"
"#{formatted_value} #{display_unit}"
else
converted_value
formatted_value
end
end

Loading…
Cancel
Save