summaryrefslogtreecommitdiff
path: root/packages/demobank-ui/src/pages/WireTransfer.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/demobank-ui/src/pages/WireTransfer.tsx')
-rw-r--r--packages/demobank-ui/src/pages/WireTransfer.tsx60
1 files changed, 46 insertions, 14 deletions
diff --git a/packages/demobank-ui/src/pages/WireTransfer.tsx b/packages/demobank-ui/src/pages/WireTransfer.tsx
index 25d43a832..190afd66e 100644
--- a/packages/demobank-ui/src/pages/WireTransfer.tsx
+++ b/packages/demobank-ui/src/pages/WireTransfer.tsx
@@ -1,18 +1,47 @@
-import { Amounts, HttpStatusCode, TalerError } from "@gnu-taler/taler-util";
-import { Loading, notifyInfo, useTranslationContext } from "@gnu-taler/web-util/browser";
+/*
+ This file is part of GNU Taler
+ (C) 2022-2024 Taler Systems S.A.
+
+ GNU Taler is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+import {
+ Amounts,
+ HttpStatusCode,
+ TalerError,
+ assertUnreachable,
+} from "@gnu-taler/taler-util";
+import {
+ Loading,
+ notifyInfo,
+ useTranslationContext,
+} from "@gnu-taler/web-util/browser";
import { Fragment, VNode, h } from "preact";
import { ErrorLoadingWithDebug } from "../components/ErrorLoadingWithDebug.js";
import { useAccountDetails } from "../hooks/access.js";
import { useBackendState } from "../hooks/backend.js";
import { LoginForm } from "./LoginForm.js";
import { PaytoWireTransferForm } from "./PaytoWireTransferForm.js";
-import { assertUnreachable } from "./WithdrawalOperationPage.js";
+import { RouteDefinition } from "../route.js";
-export function WireTransfer({ toAccount, onAuthorizationRequired, onCancel, onSuccess }: {
+export function WireTransfer({
+ toAccount,
+ onAuthorizationRequired,
+ routeCancel,
+ onSuccess,
+}: {
onSuccess?: () => void;
- toAccount?: string,
- onCancel?: () => void,
- onAuthorizationRequired: () => void,
+ toAccount?: string;
+ routeCancel?: RouteDefinition<Record<string, never>>;
+ onAuthorizationRequired: () => void;
}): VNode {
const { i18n } = useTranslationContext();
const r = useBackendState();
@@ -20,16 +49,19 @@ export function WireTransfer({ toAccount, onAuthorizationRequired, onCancel, onS
const result = useAccountDetails(account);
if (!result) {
- return <Loading />
+ return <Loading />;
}
if (result instanceof TalerError) {
- return <ErrorLoadingWithDebug error={result} />
+ return <ErrorLoadingWithDebug error={result} />;
}
if (result.type === "fail") {
switch (result.case) {
- case HttpStatusCode.Unauthorized: return <LoginForm currentUser={account} />
- case HttpStatusCode.NotFound: return <LoginForm currentUser={account} />
- default: assertUnreachable(result)
+ case HttpStatusCode.Unauthorized:
+ return <LoginForm currentUser={account} />;
+ case HttpStatusCode.NotFound:
+ return <LoginForm currentUser={account} />;
+ default:
+ assertUnreachable(result);
}
}
const { body: data } = result;
@@ -50,9 +82,9 @@ export function WireTransfer({ toAccount, onAuthorizationRequired, onCancel, onS
onAuthorizationRequired={onAuthorizationRequired}
onSuccess={() => {
notifyInfo(i18n.str`Wire transfer created!`);
- if (onSuccess) onSuccess()
+ if (onSuccess) onSuccess();
}}
- onCancel={onCancel}
+ routeCancel={routeCancel}
/>
);
}