Dashboard: Fix SATS denomination display (#4994)

When the default currency of the store is SATS, the display was broken.
This commit is contained in:
d11n 2023-05-25 03:08:00 +02:00 committed by GitHub
parent a918288e3b
commit 55203e0b64
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View file

@ -92,8 +92,7 @@
window.setTimeout(() => {
const yLabels = [...document.querySelectorAll('.ct-label.ct-vertical.ct-start')];
if (yLabels) {
const factor = rate ? 6 : 8;
const width = Math.max(...(yLabels.map(l => l.innerText.length * factor)));
const width = Math.max(...(yLabels.map(l => l.innerText.length * 7.5)));
const opts = Object.assign({}, renderOpts, {
axisY: Object.assign({}, renderOpts.axisY, { offset: width })
});

View file

@ -7,7 +7,6 @@
@using BTCPayServer.Components.AppSales
@using BTCPayServer.Components.AppTopItems
@using BTCPayServer.Services.Apps
@inject AppService AppService
@model StoreDashboardViewModel
@{
ViewData.SetActivePage(StoreNavPages.Dashboard, Model.StoreName, Model.StoreId);
@ -63,8 +62,11 @@
displayDefaultCurrency(amount, rate, currency, divisibility) {
const value = DashboardUtils.toDefaultCurrency(amount, rate);
const locale = currency === 'USD' ? 'en-US' : navigator.language;
const isSats = currency === 'SATS';
if (isSats) currency = 'BTC';
const opts = { currency, style: 'decimal', minimumFractionDigits: divisibility };
return new Intl.NumberFormat(locale, opts).format(value);
const val = new Intl.NumberFormat(locale, opts).format(value);
return isSats ? val.replace(/[\\.,]/g, ' ') : val;
},
async fetchRate(currencyPair) {
const storeId = @Safe.Json(Context.GetRouteValue("storeId"));