diff options
Diffstat (limited to 'packages/taler-wallet-webextension/src/wallet/DestinationSelection/state.ts')
-rw-r--r-- | packages/taler-wallet-webextension/src/wallet/DestinationSelection/state.ts | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/packages/taler-wallet-webextension/src/wallet/DestinationSelection/state.ts b/packages/taler-wallet-webextension/src/wallet/DestinationSelection/state.ts index 1fe324c5a..d5015ae1d 100644 --- a/packages/taler-wallet-webextension/src/wallet/DestinationSelection/state.ts +++ b/packages/taler-wallet-webextension/src/wallet/DestinationSelection/state.ts @@ -17,7 +17,7 @@ import { Amounts } from "@gnu-taler/taler-util"; import { WalletApiOperation } from "@gnu-taler/taler-wallet-core"; import { useState } from "preact/hooks"; -import { alertFromError } from "../../context/alert.js"; +import { alertFromError, useAlertContext } from "../../context/alert.js"; import { useBackendContext } from "../../context/backend.js"; import { useTranslationContext } from "../../context/translation.js"; import { useAsyncAsHook } from "../../hooks/useAsyncAsHook.js"; @@ -26,6 +26,7 @@ import { Contact, Props, State } from "./index.js"; export function useComponentState(props: Props): RecursiveState<State> { const api = useBackendContext(); + const { pushAlertOnError } = useAlertContext(); const parsedInitialAmount = !props.amount ? undefined : Amounts.parse(props.amount); @@ -108,26 +109,26 @@ export function useComponentState(props: Props): RecursiveState<State> { error: undefined, previous, selectCurrency: { - onClick: async () => { + onClick: pushAlertOnError(async () => { setAmount(undefined); - }, + }), }, goToBank: { onClick: invalid ? undefined - : async () => { + : pushAlertOnError(async () => { props.goToWalletBankDeposit(currencyAndAmount); - }, + }), }, goToWallet: { onClick: invalid ? undefined - : async () => { + : pushAlertOnError(async () => { props.goToWalletWalletSend(currencyAndAmount); - }, + }), }, amountHandler: { - onInput: async (s) => setAmount(s), + onInput: pushAlertOnError(async (s) => setAmount(s)), value: amount, }, type: props.type, @@ -138,26 +139,26 @@ export function useComponentState(props: Props): RecursiveState<State> { error: undefined, previous, selectCurrency: { - onClick: async () => { + onClick: pushAlertOnError(async () => { setAmount(undefined); - }, + }), }, goToBank: { onClick: invalid ? undefined - : async () => { + : pushAlertOnError(async () => { props.goToWalletManualWithdraw(currencyAndAmount); - }, + }), }, goToWallet: { onClick: invalid ? undefined - : async () => { + : pushAlertOnError(async () => { props.goToWalletWalletInvoice(currencyAndAmount); - }, + }), }, amountHandler: { - onInput: async (s) => setAmount(s), + onInput: pushAlertOnError(async (s) => setAmount(s)), value: amount, }, type: props.type, |