From 420493b3e608f3b245ebae308a318883f9f605f7 Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Tue, 17 Jan 2023 16:01:04 -0300
Subject: use payto builder and prevent showing cancel for non-payment

---
 .../src/wallet/Transaction.tsx                     | 38 +++++++++++++---------
 1 file changed, 22 insertions(+), 16 deletions(-)

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

diff --git a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx
index 7c0682588..397972636 100644
--- a/packages/taler-wallet-webextension/src/wallet/Transaction.tsx
+++ b/packages/taler-wallet-webextension/src/wallet/Transaction.tsx
@@ -202,20 +202,24 @@ function TransactionTemplate({
   const SHOWING_RETRY_THRESHOLD_SECS = 30;
 
   const showSend = false;
-  // (transaction.type === TransactionType.PeerPullCredit ||
-  //   transaction.type === TransactionType.PeerPushDebit) &&
-  //   !transaction.info.completed;
-  const showRetry =
-    transaction.error !== undefined ||
-    transaction.timestamp.t_s === "never" ||
-    (transaction.extendedStatus === ExtendedStatus.Pending &&
-      differenceInSeconds(new Date(), transaction.timestamp.t_s * 1000) >
-        SHOWING_RETRY_THRESHOLD_SECS);
+  const hasCancelTransactionImplemented =
+    transaction.type === TransactionType.Payment;
 
   const transactionStillActive =
     transaction.extendedStatus !== ExtendedStatus.Aborted &&
     transaction.extendedStatus !== ExtendedStatus.Done &&
     transaction.extendedStatus !== ExtendedStatus.Failed;
+
+  // show retry if there is an error in an active state, or after some time
+  // if it is not aborting
+  const showRetry =
+    transactionStillActive &&
+    (transaction.error !== undefined ||
+      (transaction.extendedStatus !== ExtendedStatus.Aborting &&
+        (transaction.timestamp.t_s === "never" ||
+          differenceInSeconds(new Date(), transaction.timestamp.t_s * 1000) >
+            SHOWING_RETRY_THRESHOLD_SECS)));
+
   return (
     <Fragment>
       <section style={{ padding: 8, textAlign: "center" }}>
@@ -353,13 +357,15 @@ function TransactionTemplate({
             </Button>
           ) : null}
           {transactionStillActive ? (
-            <Button
-              variant="contained"
-              color="error"
-              onClick={doCheckBeforeCancel as SafeHandler<void>}
-            >
-              <i18n.Translate>Cancel</i18n.Translate>
-            </Button>
+            hasCancelTransactionImplemented ? (
+              <Button
+                variant="contained"
+                color="error"
+                onClick={doCheckBeforeCancel as SafeHandler<void>}
+              >
+                <i18n.Translate>Cancel</i18n.Translate>
+              </Button>
+            ) : undefined
           ) : (
             <Button
               variant="contained"
-- 
cgit v1.2.3

