From abafae8a1bf5b8b22b09438eac1d2292b6f836f2 Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Mon, 20 May 2024 12:48:44 -0300
Subject: fix #8856 #8840

---
 .../src/cta/Withdraw/views.tsx                     | 152 ++++++++++++++++-----
 1 file changed, 120 insertions(+), 32 deletions(-)

(limited to 'packages/taler-wallet-webextension/src/cta/Withdraw/views.tsx')

diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw/views.tsx b/packages/taler-wallet-webextension/src/cta/Withdraw/views.tsx
index aade67835..cdddd9bbc 100644
--- a/packages/taler-wallet-webextension/src/cta/Withdraw/views.tsx
+++ b/packages/taler-wallet-webextension/src/cta/Withdraw/views.tsx
@@ -23,7 +23,12 @@ import { Part } from "../../components/Part.js";
 import { QR } from "../../components/QR.js";
 import { SelectList } from "../../components/SelectList.js";
 import { TermsOfService } from "../../components/TermsOfService/index.js";
-import { Input, LinkSuccess, SvgIcon, WarningBox } from "../../components/styled/index.js";
+import {
+  Input,
+  LinkSuccess,
+  SvgIcon,
+  WarningBox,
+} from "../../components/styled/index.js";
 import { Button } from "../../mui/Button.js";
 import { Grid } from "../../mui/Grid.js";
 import editIcon from "../../svg/edit_24px.inline.svg";
@@ -37,28 +42,102 @@ import { EnabledBySettings } from "../../components/EnabledBySettings.js";
 
 export function FinalStateOperation(state: State.AlreadyCompleted): VNode {
   const { i18n } = useTranslationContext();
+  // document.location.href = res.confirmTransferUrl
+  if (state.thisWallet) {
+    switch (state.operationState) {
+      case "confirmed": {
+        state.redirectToTx();
+        return (
+          <WarningBox>
+            <div style={{ justifyContent: "center", lineHeight: "25px" }}>
+              <i18n.Translate>
+                This operation has already been completed.
+              </i18n.Translate>
+            </div>
+          </WarningBox>
+        );
+      }
+      case "aborted": {
+        state.redirectToTx();
+        return (
+          <WarningBox>
+            <div style={{ justifyContent: "center", lineHeight: "25px" }}>
+              <i18n.Translate>
+                This operation has already been aborted
+              </i18n.Translate>
+            </div>
+          </WarningBox>
+        );
+      }
+      case "selected": {
+        if (state.confirmTransferUrl) {
+          document.location.href = state.confirmTransferUrl;
+        }
+        return (
+          <WarningBox>
+            <div style={{ justifyContent: "center", lineHeight: "25px" }}>
+              <i18n.Translate>
+                This operation has started and should be completed in the bank.
+              </i18n.Translate>
+            </div>
+            {state.confirmTransferUrl && (
+              <div style={{ justifyContent: "center", lineHeight: "25px" }}>
+                <i18n.Translate>
+                  You can confirm the operation in
+                </i18n.Translate>
+                &nbsp;
+                <a
+                  target="_bank"
+                  rel="noreferrer"
+                  href={state.confirmTransferUrl}
+                >
+                  <i18n.Translate>this page</i18n.Translate>
+                </a>
+              </div>
+            )}
+          </WarningBox>
+        );
+      }
+    }
+  }
 
   switch (state.operationState) {
-    case "confirmed": return <WarningBox>
-      <div style={{ justifyContent: "center", lineHeight: "25px" }}>
-        <i18n.Translate>This operation has already been completed by another wallet.</i18n.Translate>
-      </div>
-    </WarningBox>
-    case "aborted": return <WarningBox>
-      <div style={{ justifyContent: "center", lineHeight: "25px" }}>
-        <i18n.Translate>This operation has already been aborted</i18n.Translate>
-      </div>
-    </WarningBox>
-    case "selected": return <WarningBox>
-      <div style={{ justifyContent: "center", lineHeight: "25px" }}>
-        <i18n.Translate>This operation has already been used by another wallet.</i18n.Translate>
-      </div>
-      <div style={{ justifyContent: "center", lineHeight: "25px" }}>
-        <i18n.Translate>It can be confirmed in</i18n.Translate>&nbsp;<a target="_bank" rel="noreferrer" href={state.confirmTransferUrl}>
-          <i18n.Translate>this page</i18n.Translate>
-        </a>
-      </div>
-    </WarningBox>
+    case "confirmed":
+      return (
+        <WarningBox>
+          <div style={{ justifyContent: "center", lineHeight: "25px" }}>
+            <i18n.Translate>
+              This operation has already been completed by another wallet.
+            </i18n.Translate>
+          </div>
+        </WarningBox>
+      );
+    case "aborted":
+      return (
+        <WarningBox>
+          <div style={{ justifyContent: "center", lineHeight: "25px" }}>
+            <i18n.Translate>
+              This operation has already been aborted
+            </i18n.Translate>
+          </div>
+        </WarningBox>
+      );
+    case "selected":
+      return (
+        <WarningBox>
+          <div style={{ justifyContent: "center", lineHeight: "25px" }}>
+            <i18n.Translate>
+              This operation has already been used by another wallet.
+            </i18n.Translate>
+          </div>
+          <div style={{ justifyContent: "center", lineHeight: "25px" }}>
+            <i18n.Translate>It can be confirmed in</i18n.Translate>&nbsp;
+            <a target="_bank" rel="noreferrer" href={state.confirmTransferUrl}>
+              <i18n.Translate>this page</i18n.Translate>
+            </a>
+          </div>
+        </WarningBox>
+      );
   }
 }
 
@@ -95,21 +174,31 @@ export function SuccessView(state: State.Success): VNode {
           kind="neutral"
           big
         />
-        {state.chooseCurrencies.length > 0 ?
+        {state.chooseCurrencies.length > 0 ? (
           <Fragment>
             <p>
-              {state.chooseCurrencies.map(currency => {
-                return <Button variant={currency === state.selectedCurrency ? "contained" : "outlined"}
-                  onClick={async () => {
-                    state.changeCurrency(currency)
-                  }}
-                >
-                  {currency}
-                </Button>
+              {state.chooseCurrencies.map((currency) => {
+                return (
+                  <Button
+                    key={currency}
+                    variant={
+                      currency === state.selectedCurrency
+                        ? "contained"
+                        : "outlined"
+                    }
+                    onClick={async () => {
+                      state.changeCurrency(currency);
+                    }}
+                  >
+                    {currency}
+                  </Button>
+                );
               })}
             </p>
           </Fragment>
-          : <Fragment />}
+        ) : (
+          <Fragment />
+        )}
 
         <Part
           title={i18n.str`Details`}
@@ -202,7 +291,6 @@ function WithdrawWithMobile({
 }
 
 export function SelectAmountView({
-  currency,
   amount,
   exchangeBaseUrl,
   confirm,
-- 
cgit v1.2.3

