From 2f3eedea5b9b8cf1d6cae503a2cb12239af1014e Mon Sep 17 00:00:00 2001 From: d11n Date: Sat, 8 Jul 2023 17:33:13 +0200 Subject: [PATCH] Invoice lists: Show icons for payment methods (#5137) --- .../StoreRecentInvoices/Default.cshtml | 51 ++++++---- .../Views/UIInvoice/ListInvoices.cshtml | 99 +++++++++++-------- 2 files changed, 91 insertions(+), 59 deletions(-) diff --git a/BTCPayServer/Components/StoreRecentInvoices/Default.cshtml b/BTCPayServer/Components/StoreRecentInvoices/Default.cshtml index eb0c45ed8..360ca7d7c 100644 --- a/BTCPayServer/Components/StoreRecentInvoices/Default.cshtml +++ b/BTCPayServer/Components/StoreRecentInvoices/Default.cshtml @@ -3,6 +3,7 @@ @using BTCPayServer.Services @using BTCPayServer.Services.Invoices @inject DisplayFormatter DisplayFormatter +@inject PaymentMethodHandlerDictionary PaymentMethodHandlerDictionary @model BTCPayServer.Components.StoreRecentInvoices.StoreRecentInvoicesViewModel
@@ -51,27 +52,41 @@ @invoice.InvoiceId - @if (invoice.Details.Archived) - { - archived - } - - @invoice.Status.Status.ToModernStatus().ToString() - @if (invoice.Status.ExceptionStatus != InvoiceExceptionStatus.None) +
+ @if (invoice.Details.Archived) { - @($"({invoice.Status.ExceptionStatus.ToString()})") + archived } - - @foreach (var paymentType in invoice.Details.Payments.Select(payment => payment.GetPaymentMethodId()?.PaymentType).Distinct().Where(type => type != null && !string.IsNullOrEmpty(type.GetBadge()))) - { - @paymentType.GetBadge() - } - @if (invoice.HasRefund) - { - - Refund + + @invoice.Status.Status.ToModernStatus().ToString() + @if (invoice.Status.ExceptionStatus != InvoiceExceptionStatus.None) + { + @($"({invoice.Status.ExceptionStatus.ToString()})") + } - } + @foreach (var paymentMethodId in invoice.Details.Payments.Select(payment => payment.GetPaymentMethodId()).Distinct()) + { + var image = PaymentMethodHandlerDictionary[paymentMethodId]?.GetCryptoImage(paymentMethodId); + var badge = paymentMethodId.PaymentType.GetBadge(); + if (!string.IsNullOrEmpty(image) || !string.IsNullOrEmpty(badge)) + { + + @if (!string.IsNullOrEmpty(image)) + { + @paymentMethodId.PaymentType.ToString() + } + @if (!string.IsNullOrEmpty(badge)) + { + @badge + } + + } + } + @if (invoice.HasRefund) + { + Refund + } +
@DisplayFormatter.Currency(invoice.Amount, invoice.Currency) diff --git a/BTCPayServer/Views/UIInvoice/ListInvoices.cshtml b/BTCPayServer/Views/UIInvoice/ListInvoices.cshtml index 6368fa529..3acf06795 100644 --- a/BTCPayServer/Views/UIInvoice/ListInvoices.cshtml +++ b/BTCPayServer/Views/UIInvoice/ListInvoices.cshtml @@ -2,6 +2,7 @@ @using BTCPayServer.Client.Models @using BTCPayServer.Services @inject DisplayFormatter DisplayFormatter +@inject PaymentMethodHandlerDictionary PaymentMethodHandlerDictionary @model InvoicesModel @{ ViewData.SetActivePage(InvoiceNavPages.Index, "Invoices"); @@ -391,50 +392,66 @@ @invoice.InvoiceId - @if (invoice.Details.Archived) - { - archived - } - @if (invoice.CanMarkStatus) - { -
- - @DisplayFormatter.Currency(invoice.Amount, invoice.Currency)