umbrel-dashboard
umbrel-dashboard copied to clipboard
fix rounding in satsToUSD view
This pull request fixes an issue with the USD balance view on the dashboard.
Essentially, the rounding is done in a way where the USD value can round to a single decimal place, even though USD values are properly represented with two decimal places.
This is essentially the logic that exists today:
"$" + Number(150.1.toFixed(2)).toLocaleString()
The problem with this is that casting to Number() removes the attempt at pinning the number of decimals via .toFixed().
The solution is to use Numbers native currency styling support:
Number("150.1").toLocaleString(Intl.NumberFormat().resolvedOptions().locale, {currency: 'usd', style: 'currency'})
Then it looks correct
