From 8407a1d52e3a89f9c005f9820586d2d0a123c177 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 4 Dec 2023 09:43:03 -0300 Subject: api sync, withdrawal info without password, account creation WIP --- .../src/pages/WithdrawalConfirmationQuestion.tsx | 153 ++++++++++++--------- 1 file changed, 90 insertions(+), 63 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 e21c0917b..f8913f0ec 100644 --- a/packages/demobank-ui/src/pages/WithdrawalConfirmationQuestion.tsx +++ b/packages/demobank-ui/src/pages/WithdrawalConfirmationQuestion.tsx @@ -25,13 +25,14 @@ import { WithdrawUriResult } from "@gnu-taler/taler-util"; import { + Attention, ErrorLoading, Loading, notifyInfo, useLocalNotification, useTranslationContext } from "@gnu-taler/web-util/browser"; -import { Fragment, VNode, h } from "preact"; +import { ComponentChildren, Fragment, VNode, h } from "preact"; import { useMemo, useState } from "preact/hooks"; import { mutate } from "swr"; import { ShowInputErrorLabel } from "@gnu-taler/web-util/browser"; @@ -45,6 +46,7 @@ import { useBackendState } from "../hooks/backend.js"; import { useWithdrawalDetails } from "../hooks/access.js"; import { OperationState } from "./OperationState/index.js"; import { OperationNotFound } from "./WithdrawalQRCode.js"; +import { ErrorLoadingWithDebug } from "../components/ErrorLoadingWithDebug.js"; const logger = new Logger("WithdrawalConfirmationQuestion"); @@ -54,6 +56,7 @@ interface Props { details: { account: PaytoUri, reserve: string, + username: string, amount: AmountJson, } } @@ -75,15 +78,16 @@ export function WithdrawalConfirmationQuestion({ return } if (withdrawalInfo instanceof TalerError) { - return + return } if (withdrawalInfo.type === "fail") { - switch(withdrawalInfo.case) { - case "not-found": return - default: assertUnreachable(withdrawalInfo.case) + switch (withdrawalInfo.case) { + case "not-found": return + case "invalid-id": return + default: assertUnreachable(withdrawalInfo) } } - + const captchaNumbers = useMemo(() => { return { a: Math.floor(Math.random() * 10), @@ -200,67 +204,70 @@ export function WithdrawalConfirmationQuestion({
-
-
-

Answer the next question to authorize the wire transfer.

-
-
{ - e.preventDefault() - }} - > -
- -
-
- +
+
+

Answer the next question to authorize the wire transfer.

+
+ { + e.preventDefault() + }} + > +
+ + +
+
+ { - setCaptchaAnswer(e.currentTarget.value) - }} - /> + name="answer" + id="answer" + autocomplete="off" + onChange={(e): void => { + setCaptchaAnswer(e.currentTarget.value) + }} + /> +
+
-
-
-
- - -
+
+ + +
- -
+ +
+
@@ -325,6 +332,26 @@ export function WithdrawalConfirmationQuestion({
- + ); } + +export function ShouldBeSameUser({ username, children }: { username: string, children: ComponentChildren }): VNode { + const { state: credentials } = useBackendState(); + const { i18n } = useTranslationContext() + if (credentials.status === "loggedOut") { + return +

You should login as "{username}"

+
+ } + if (credentials.username !== username) { + return +

+ You can switch to account "{username}" and complete the operation. +

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