diff options
Diffstat (limited to 'packages/taler-wallet-webextension/src/wallet/DepositPage/state.ts')
-rw-r--r-- | packages/taler-wallet-webextension/src/wallet/DepositPage/state.ts | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/packages/taler-wallet-webextension/src/wallet/DepositPage/state.ts b/packages/taler-wallet-webextension/src/wallet/DepositPage/state.ts index b597c77be..935adf012 100644 --- a/packages/taler-wallet-webextension/src/wallet/DepositPage/state.ts +++ b/packages/taler-wallet-webextension/src/wallet/DepositPage/state.ts @@ -25,7 +25,7 @@ import { } 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"; @@ -39,6 +39,7 @@ export function useComponentState({ }: Props): State { const api = useBackendContext(); const { i18n } = useTranslationContext(); + const { pushAlertOnError } = useAlertContext(); const parsed = amountStr === undefined ? undefined : Amounts.parse(amountStr); const currency = parsed !== undefined ? parsed.currency : currencyStr; @@ -130,9 +131,9 @@ export function useComponentState({ error: undefined, currency, onAddAccount: { - onClick: async () => { + onClick: pushAlertOnError(async () => { setAddingAccount(true); - }, + }), }, }; } @@ -221,27 +222,27 @@ export function useComponentState({ currency, amount: { value: amount, - onInput: updateAmount, + onInput: pushAlertOnError(updateAmount), error: amountError, }, onAddAccount: { - onClick: async () => { + onClick: pushAlertOnError(async () => { setAddingAccount(true); - }, + }), }, account: { list: accountMap, value: stringifyPaytoUri(currentAccount), - onChange: updateAccountFromList, + onChange: pushAlertOnError(updateAccountFromList), }, currentAccount, cancelHandler: { - onClick: async () => { + onClick: pushAlertOnError(async () => { onCancel(currency); - }, + }), }, depositHandler: { - onClick: unableToDeposit ? undefined : doSend, + onClick: unableToDeposit ? undefined : pushAlertOnError(doSend), }, totalFee, totalToDeposit, @@ -263,7 +264,7 @@ async function getFeeForAmount( }); } -export function labelForAccountType(id: string) { +export function labelForAccountType(id: string): string { switch (id) { case "": return "Choose one"; |