From a3aa7d95d09c83794067c47df4a455c0e3f21806 Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Fri, 7 Apr 2023 17:30:01 -0300
Subject: anon withdrawal confirmation, and fix error with infinity loop

---
 packages/demobank-ui/src/pages/PaymentOptions.tsx | 30 +++++++++--------------
 1 file changed, 12 insertions(+), 18 deletions(-)

(limited to 'packages/demobank-ui/src/pages/PaymentOptions.tsx')

diff --git a/packages/demobank-ui/src/pages/PaymentOptions.tsx b/packages/demobank-ui/src/pages/PaymentOptions.tsx
index 291f2aa9e..e0ad64e64 100644
--- a/packages/demobank-ui/src/pages/PaymentOptions.tsx
+++ b/packages/demobank-ui/src/pages/PaymentOptions.tsx
@@ -17,8 +17,13 @@
 import { AmountJson } from "@gnu-taler/taler-util";
 import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser";
 import { h, VNode } from "preact";
-import { useState } from "preact/hooks";
-import { PageStateType, usePageContext } from "../context/pageState.js";
+import { StateUpdater, useState } from "preact/hooks";
+import {
+  notifyError,
+  notifyInfo,
+  PageStateType,
+  usePageContext,
+} from "../context/pageState.js";
 import { PaytoWireTransferForm } from "./PaytoWireTransferForm.js";
 import { WalletWithdrawForm } from "./WalletWithdrawForm.js";
 
@@ -33,9 +38,6 @@ export function PaymentOptions({ limit }: { limit: AmountJson }): VNode {
   const [tab, setTab] = useState<"charge-wallet" | "wire-transfer">(
     "charge-wallet",
   );
-  function saveError(error: PageStateType["error"]): void {
-    pageStateSetter((prev) => ({ ...prev, error }));
-  }
 
   return (
     <article>
@@ -64,15 +66,11 @@ export function PaymentOptions({ limit }: { limit: AmountJson }): VNode {
             <WalletWithdrawForm
               focus
               limit={limit}
-              onSuccess={(data) => {
-                pageStateSetter((prevState: PageStateType) => ({
-                  ...prevState,
-                  withdrawalInProgress: true,
-                  talerWithdrawUri: data.taler_withdraw_uri,
-                  withdrawalId: data.withdrawal_id,
-                }));
+              onSuccess={(currentWithdrawalOperationId) => {
+                pageStateSetter({
+                  currentWithdrawalOperationId,
+                });
               }}
-              onError={saveError}
             />
           </div>
         )}
@@ -83,12 +81,8 @@ export function PaymentOptions({ limit }: { limit: AmountJson }): VNode {
               focus
               limit={limit}
               onSuccess={() => {
-                pageStateSetter((prevState: PageStateType) => ({
-                  ...prevState,
-                  info: i18n.str`Wire transfer created!`,
-                }));
+                notifyInfo(i18n.str`Wire transfer created!`);
               }}
-              onError={saveError}
             />
           </div>
         )}
-- 
cgit v1.2.3

