From 366cccb8fcae6a9971a1e8a9143d821e289339d1 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 19 Oct 2023 02:55:57 -0300 Subject: integrate bank into the new taler-util API --- .../demobank-ui/src/pages/WithdrawalQRCode.tsx | 98 ++++++++++++---------- 1 file changed, 54 insertions(+), 44 deletions(-) (limited to 'packages/demobank-ui/src/pages/WithdrawalQRCode.tsx') diff --git a/packages/demobank-ui/src/pages/WithdrawalQRCode.tsx b/packages/demobank-ui/src/pages/WithdrawalQRCode.tsx index 35fb94a6c..15910201e 100644 --- a/packages/demobank-ui/src/pages/WithdrawalQRCode.tsx +++ b/packages/demobank-ui/src/pages/WithdrawalQRCode.tsx @@ -16,17 +16,17 @@ import { Amounts, - HttpStatusCode, Logger, + TalerError, WithdrawUriResult, parsePaytoUri } from "@gnu-taler/taler-util"; -import { ErrorType, notifyInfo, useTranslationContext } from "@gnu-taler/web-util/browser"; +import { notifyInfo, useTranslationContext } from "@gnu-taler/web-util/browser"; import { Fragment, VNode, h } from "preact"; +import { ErrorLoading } from "../components/ErrorLoading.js"; import { Loading } from "../components/Loading.js"; import { useWithdrawalDetails } from "../hooks/access.js"; -import { useSettings } from "../hooks/settings.js"; -import { handleNotOkResult } from "./HomePage.js"; +import { assertUnreachable } from "./HomePage.js"; import { QrCodeSection } from "./QrCodeSection.js"; import { WithdrawalConfirmationQuestion } from "./WithdrawalConfirmationQuestion.js"; @@ -48,48 +48,20 @@ export function WithdrawalQRCode({ const { i18n } = useTranslationContext(); const result = useWithdrawalDetails(withdrawUri.withdrawalOperationId); - if (!result.ok) { - if (result.loading) { - return ; - } - if (result.type === ErrorType.CLIENT && result.status === HttpStatusCode.NotFound) { - return
-
-
- -
- -
- -
-

- - This operation is not known by the server. The operation id is wrong or the - server deleted the operation information before reaching here. - -

-
-
-
-
- -
-
+ if (!result) { + return + } + if (result instanceof TalerError) { + return + } + if (result.type === "fail") { + switch (result.case) { + case "not-found": return + default: assertUnreachable(result.case) } - return handleNotOkResult(i18n)(result); } - const { data } = result; + + const { body: data } = result; if (data.aborted) { return
@@ -194,3 +166,41 @@ export function WithdrawalQRCode({ /> ); } + + +function OperationNotFound({ onClose }: { onClose: () => void }): VNode { + const { i18n } = useTranslationContext(); + return
+
+
+ +
+ +
+ +
+

+ + This operation is not known by the server. The operation id is wrong or the + server deleted the operation information before reaching here. + +

+
+
+
+
+ +
+
+} \ No newline at end of file -- cgit v1.2.3