From 55203e0b64b9abf6faf935a57072b78679e95213 Mon Sep 17 00:00:00 2001 From: d11n Date: Thu, 25 May 2023 03:08:00 +0200 Subject: [PATCH] Dashboard: Fix SATS denomination display (#4994) When the default currency of the store is SATS, the display was broken. --- BTCPayServer/Components/StoreWalletBalance/Default.cshtml | 3 +-- BTCPayServer/Views/UIStores/Dashboard.cshtml | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/BTCPayServer/Components/StoreWalletBalance/Default.cshtml b/BTCPayServer/Components/StoreWalletBalance/Default.cshtml index de72c78a4..bc912d926 100644 --- a/BTCPayServer/Components/StoreWalletBalance/Default.cshtml +++ b/BTCPayServer/Components/StoreWalletBalance/Default.cshtml @@ -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 }) }); diff --git a/BTCPayServer/Views/UIStores/Dashboard.cshtml b/BTCPayServer/Views/UIStores/Dashboard.cshtml index d4c338407..609609cc4 100644 --- a/BTCPayServer/Views/UIStores/Dashboard.cshtml +++ b/BTCPayServer/Views/UIStores/Dashboard.cshtml @@ -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"));