From 768838285c25cbb1b171f645e8efb37a3c14273a Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Mon, 30 Oct 2023 15:27:25 -0300
Subject: local error impl: errors shown fixed position that are wiped when
 moved from the view

---
 .../src/pages/WithdrawalConfirmationQuestion.tsx   | 23 +++++++++++-----------
 1 file changed, 11 insertions(+), 12 deletions(-)

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

diff --git a/packages/demobank-ui/src/pages/WithdrawalConfirmationQuestion.tsx b/packages/demobank-ui/src/pages/WithdrawalConfirmationQuestion.tsx
index 5e0fa322f..89538e305 100644
--- a/packages/demobank-ui/src/pages/WithdrawalConfirmationQuestion.tsx
+++ b/packages/demobank-ui/src/pages/WithdrawalConfirmationQuestion.tsx
@@ -16,32 +16,28 @@
 
 import {
   AmountJson,
-  Amounts,
-  HttpStatusCode,
   Logger,
   PaytoUri,
   PaytoUriIBAN,
   PaytoUriTalerBank,
-  TalerError,
   TranslatedString,
   WithdrawUriResult
 } from "@gnu-taler/taler-util";
 import {
-  RequestError,
-  notify,
-  notifyError,
   notifyInfo,
-  useTranslationContext,
+  useLocalNotification,
+  useTranslationContext
 } from "@gnu-taler/web-util/browser";
 import { Fragment, VNode, h } from "preact";
 import { useMemo, useState } from "preact/hooks";
+import { mutate } from "swr";
 import { ShowInputErrorLabel } from "../components/ShowInputErrorLabel.js";
-import { buildRequestErrorMessage, undefinedIfEmpty, withRuntimeErrorHandling } from "../utils.js";
+import { useBankCoreApiContext } from "../context/config.js";
 import { useSettings } from "../hooks/settings.js";
+import { undefinedIfEmpty, withRuntimeErrorHandling } from "../utils.js";
 import { RenderAmount } from "./PaytoWireTransferForm.js";
-import { useBankCoreApiContext } from "../context/config.js";
 import { assertUnreachable } from "./WithdrawalOperationPage.js";
-import { mutate } from "swr";
+import { ShowLocalNotification } from "../components/ShowLocalNotification.js";
 
 const logger = new Logger("WithdrawalConfirmationQuestion");
 
@@ -72,6 +68,7 @@ export function WithdrawalConfirmationQuestion({
       b: Math.floor(Math.random() * 10),
     };
   }, []);
+  const [notification, notify, handleError] = useLocalNotification()
 
   const { api } = useBankCoreApiContext()
   const [captchaAnswer, setCaptchaAnswer] = useState<string | undefined>();
@@ -89,7 +86,7 @@ export function WithdrawalConfirmationQuestion({
 
   async function doTransfer() {
     setBusy({})
-    await withRuntimeErrorHandling(i18n, async () => {
+    await handleError(async () => {
       const resp = await api.confirmWithdrawalById(withdrawUri.withdrawalOperationId);
       if (resp.type === "ok") {
         mutate(() => true)// clean any info that we have
@@ -131,7 +128,7 @@ export function WithdrawalConfirmationQuestion({
 
   async function doCancel() {
     setBusy({})
-    await withRuntimeErrorHandling(i18n, async () => {
+    await handleError(async () => {
       const resp = await api.abortWithdrawalById(withdrawUri.withdrawalOperationId);
       if (resp.type === "ok") {
         onAborted();
@@ -164,6 +161,8 @@ export function WithdrawalConfirmationQuestion({
 
   return (
     <Fragment>
+          <ShowLocalNotification notification={notification} />
+
       <div class="bg-white shadow sm:rounded-lg">
         <div class="px-4 py-5 sm:p-6">
           <h3 class="text-base font-semibold text-gray-900">
-- 
cgit v1.2.3

