diff options
author | Sebastian <sebasjm@gmail.com> | 2023-04-07 17:30:01 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-04-07 17:30:01 -0300 |
commit | a3aa7d95d09c83794067c47df4a455c0e3f21806 (patch) | |
tree | 00837196305227fe6f7cbc7289f96b256d5de089 /packages/demobank-ui/src/pages/BusinessAccount.tsx | |
parent | 43ae414a55b84b1125c5e4377c6d485ca6c748e2 (diff) | |
download | wallet-core-a3aa7d95d09c83794067c47df4a455c0e3f21806.tar.xz |
anon withdrawal confirmation, and fix error with infinity loop
Diffstat (limited to 'packages/demobank-ui/src/pages/BusinessAccount.tsx')
-rw-r--r-- | packages/demobank-ui/src/pages/BusinessAccount.tsx | 44 |
1 files changed, 22 insertions, 22 deletions
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: <T>( - error: HttpResponsePaginated<T, SandboxBackend.SandboxError>, - ) => 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 <LoginForm onRegister={onRegister} />; @@ -82,12 +80,12 @@ export function BusinessAccount({ return ( <CreateCashout account={backend.state.username} - onLoadNotOk={onLoadNotOk} + onLoadNotOk={handleNotOkResult(i18n, onRegister)} onCancel={() => { 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 ( <ShowCashoutDetails id={showCashoutDetails} - onLoadNotOk={onLoadNotOk} + onLoadNotOk={handleNotOkResult(i18n, onRegister)} onCancel={() => { setShowCashoutDetails(undefined); }} @@ -111,9 +109,9 @@ export function BusinessAccount({ return ( <UpdateAccountPassword account={backend.state.username} - onLoadNotOk={onLoadNotOk} + onLoadNotOk={handleNotOkResult(i18n, onRegister)} onUpdateSuccess={() => { - showInfoMessage(i18n.str`Password changed`); + notifyInfo(i18n.str`Password changed`); setUpdatePassword(false); }} onClear={() => { @@ -126,9 +124,9 @@ export function BusinessAccount({ <div> <ShowAccountDetails account={backend.state.username} - onLoadNotOk={onLoadNotOk} + onLoadNotOk={handleNotOkResult(i18n, onRegister)} onUpdateSuccess={() => { - 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: <T>( - error: HttpResponsePaginated<T, SandboxBackend.SandboxError>, + error: + | HttpResponsePaginated<T, SandboxBackend.SandboxError> + | HttpResponse<T, SandboxBackend.SandboxError>, ) => VNode; } |