From a3aa7d95d09c83794067c47df4a455c0e3f21806 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 7 Apr 2023 17:30:01 -0300 Subject: anon withdrawal confirmation, and fix error with infinity loop --- packages/demobank-ui/src/pages/BusinessAccount.tsx | 44 +++++++++++----------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'packages/demobank-ui/src/pages/BusinessAccount.tsx') diff --git a/packages/demobank-ui/src/pages/BusinessAccount.tsx b/packages/demobank-ui/src/pages/BusinessAccount.tsx index 262376fa2..02e64ac39 100644 --- a/packages/demobank-ui/src/pages/BusinessAccount.tsx +++ b/packages/demobank-ui/src/pages/BusinessAccount.tsx @@ -25,11 +25,17 @@ import { RequestError, useTranslationContext, } from "@gnu-taler/web-util/lib/index.browser"; -import { Fragment, h, VNode } from "preact"; -import { useEffect, useMemo, useState } from "preact/hooks"; +import { Fragment, VNode, h } from "preact"; +import { StateUpdater, useEffect, useState } from "preact/hooks"; import { Cashouts } from "../components/Cashouts/index.js"; import { useBackendContext } from "../context/backend.js"; -import { ErrorMessage, usePageContext } from "../context/pageState.js"; +import { + ErrorMessage, + ObservedStateType, + PageStateType, + notifyInfo, + usePageContext, +} from "../context/pageState.js"; import { useAccountDetails } from "../hooks/access.js"; import { useCashoutDetails, @@ -38,21 +44,20 @@ import { useRatiosAndFeeConfig, } from "../hooks/circuit.js"; import { - buildRequestErrorMessage, TanChannel, + buildRequestErrorMessage, undefinedIfEmpty, } from "../utils.js"; import { ShowAccountDetails, UpdateAccountPassword } from "./AdminPage.js"; import { ErrorBannerFloat } from "./BankFrame.js"; import { LoginForm } from "./LoginForm.js"; import { ShowInputErrorLabel } from "./ShowInputErrorLabel.js"; +import { handleNotOkResult } from "./HomePage.js"; interface Props { onClose: () => void; onRegister: () => void; - onLoadNotOk: ( - error: HttpResponsePaginated, - ) => VNode; + onLoadNotOk: () => void; } export function BusinessAccount({ onClose, @@ -60,19 +65,12 @@ export function BusinessAccount({ onRegister, }: Props): VNode { const { i18n } = useTranslationContext(); - const { pageStateSetter } = usePageContext(); const backend = useBackendContext(); const [updatePassword, setUpdatePassword] = useState(false); const [newCashout, setNewcashout] = useState(false); const [showCashoutDetails, setShowCashoutDetails] = useState< string | undefined >(); - function showInfoMessage(info: TranslatedString): void { - pageStateSetter((prev) => ({ - ...prev, - info, - })); - } if (backend.state.status === "loggedOut") { return ; @@ -82,12 +80,12 @@ export function BusinessAccount({ return ( { setNewcashout(false); }} onComplete={(id) => { - showInfoMessage( + notifyInfo( i18n.str`Cashout created. You need to confirm the operation to complete the transaction.`, ); setNewcashout(false); @@ -100,7 +98,7 @@ export function BusinessAccount({ return ( { setShowCashoutDetails(undefined); }} @@ -111,9 +109,9 @@ export function BusinessAccount({ return ( { - showInfoMessage(i18n.str`Password changed`); + notifyInfo(i18n.str`Password changed`); setUpdatePassword(false); }} onClear={() => { @@ -126,9 +124,9 @@ export function BusinessAccount({
{ - showInfoMessage(i18n.str`Account updated`); + notifyInfo(i18n.str`Account updated`); }} onChangePassword={() => { setUpdatePassword(true); @@ -168,7 +166,9 @@ interface PropsCashout { onComplete: (id: string) => void; onCancel: () => void; onLoadNotOk: ( - error: HttpResponsePaginated, + error: + | HttpResponsePaginated + | HttpResponse, ) => VNode; } -- cgit v1.2.3