From 9bafc6864b9e0ef237b6975165f23ba31f0d8d88 Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Thu, 11 Apr 2024 23:48:55 -0300
Subject: fix AML spa memo and fix #8615

---
 .../src/components/BankDetailsByPaytoType.tsx              | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

(limited to 'packages/taler-wallet-webextension/src/components/BankDetailsByPaytoType.tsx')

diff --git a/packages/taler-wallet-webextension/src/components/BankDetailsByPaytoType.tsx b/packages/taler-wallet-webextension/src/components/BankDetailsByPaytoType.tsx
index 3bcf2d6ba..007c840c6 100644
--- a/packages/taler-wallet-webextension/src/components/BankDetailsByPaytoType.tsx
+++ b/packages/taler-wallet-webextension/src/components/BankDetailsByPaytoType.tsx
@@ -42,14 +42,19 @@ export interface BankDetailsProps {
 export function BankDetailsByPaytoType({
   subject,
   amount,
-  accounts,
+  accounts: unsortedAccounts,
 }: BankDetailsProps): VNode {
   const { i18n } = useTranslationContext();
   const [index, setIndex] = useState(0)
-  // const [currency, setCurrency] = useState(amount.currency)
-  if (!accounts.length) {
+
+  if (!unsortedAccounts.length) {
     return <div>the exchange account list is empty</div>
   }
+
+  const accounts = unsortedAccounts.sort((a, b) => {
+    return (b.priority ?? 0) - (a.priority ?? 0)
+  })
+
   const selectedAccount = accounts[index];
   const altCurrency = selectedAccount.currencySpecification?.name
 
@@ -83,12 +88,13 @@ export function BankDetailsByPaytoType({
       {accounts.length > 1 ?
         <Fragment>
           {accounts.map((ac, acIdx) => {
+            const accountLabel = ac.bankLabel ?? `Account #${acIdx + 1}`
             return <Button key={acIdx} variant={acIdx === index ? "contained" : "outlined"}
               onClick={async () => {
                 setIndex(acIdx)
               }}
             >
-              <i18n.Translate>Account #{acIdx+1} ({ac.currencySpecification?.name ?? amount.currency})</i18n.Translate>
+              {accountLabel} ({ac.currencySpecification?.name ?? amount.currency})
             </Button>
           })}
 
-- 
cgit v1.2.3

