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/PaymentOptions.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/PaymentOptions.tsx')
-rw-r--r-- | packages/demobank-ui/src/pages/PaymentOptions.tsx | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/packages/demobank-ui/src/pages/PaymentOptions.tsx b/packages/demobank-ui/src/pages/PaymentOptions.tsx index 291f2aa9e..e0ad64e64 100644 --- a/packages/demobank-ui/src/pages/PaymentOptions.tsx +++ b/packages/demobank-ui/src/pages/PaymentOptions.tsx @@ -17,8 +17,13 @@ import { AmountJson } from "@gnu-taler/taler-util"; import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser"; import { h, VNode } from "preact"; -import { useState } from "preact/hooks"; -import { PageStateType, usePageContext } from "../context/pageState.js"; +import { StateUpdater, useState } from "preact/hooks"; +import { + notifyError, + notifyInfo, + PageStateType, + usePageContext, +} from "../context/pageState.js"; import { PaytoWireTransferForm } from "./PaytoWireTransferForm.js"; import { WalletWithdrawForm } from "./WalletWithdrawForm.js"; @@ -33,9 +38,6 @@ export function PaymentOptions({ limit }: { limit: AmountJson }): VNode { const [tab, setTab] = useState<"charge-wallet" | "wire-transfer">( "charge-wallet", ); - function saveError(error: PageStateType["error"]): void { - pageStateSetter((prev) => ({ ...prev, error })); - } return ( <article> @@ -64,15 +66,11 @@ export function PaymentOptions({ limit }: { limit: AmountJson }): VNode { <WalletWithdrawForm focus limit={limit} - onSuccess={(data) => { - pageStateSetter((prevState: PageStateType) => ({ - ...prevState, - withdrawalInProgress: true, - talerWithdrawUri: data.taler_withdraw_uri, - withdrawalId: data.withdrawal_id, - })); + onSuccess={(currentWithdrawalOperationId) => { + pageStateSetter({ + currentWithdrawalOperationId, + }); }} - onError={saveError} /> </div> )} @@ -83,12 +81,8 @@ export function PaymentOptions({ limit }: { limit: AmountJson }): VNode { focus limit={limit} onSuccess={() => { - pageStateSetter((prevState: PageStateType) => ({ - ...prevState, - info: i18n.str`Wire transfer created!`, - })); + notifyInfo(i18n.str`Wire transfer created!`); }} - onError={saveError} /> </div> )} |