diff options
Diffstat (limited to 'packages/demobank-ui/src/pages/PaytoWireTransferForm.tsx')
-rw-r--r-- | packages/demobank-ui/src/pages/PaytoWireTransferForm.tsx | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/packages/demobank-ui/src/pages/PaytoWireTransferForm.tsx b/packages/demobank-ui/src/pages/PaytoWireTransferForm.tsx index 63cb3e865..6649d224e 100644 --- a/packages/demobank-ui/src/pages/PaytoWireTransferForm.tsx +++ b/packages/demobank-ui/src/pages/PaytoWireTransferForm.tsx @@ -18,33 +18,30 @@ import { AmountJson, AmountString, Amounts, - HttpStatusCode, Logger, - TalerError, + PaytoString, TranslatedString, buildPayto, parsePaytoUri, stringifyPaytoUri } from "@gnu-taler/taler-util"; import { - RequestError, - notify, - notifyError, - useTranslationContext, + useLocalNotification, + useTranslationContext } from "@gnu-taler/web-util/browser"; import { Fragment, Ref, VNode, h } from "preact"; -import { useEffect, useRef, useState } from "preact/hooks"; +import { useState } from "preact/hooks"; +import { mutate } from "swr"; import { ShowInputErrorLabel } from "../components/ShowInputErrorLabel.js"; +import { useBankCoreApiContext } from "../context/config.js"; +import { useBackendState } from "../hooks/backend.js"; import { - buildRequestErrorMessage, undefinedIfEmpty, validateIBAN, - withRuntimeErrorHandling, + withRuntimeErrorHandling } from "../utils.js"; -import { useBankCoreApiContext } from "../context/config.js"; -import { useBackendState } from "../hooks/backend.js"; import { assertUnreachable } from "./WithdrawalOperationPage.js"; -import { mutate } from "swr"; +import { ShowLocalNotification } from "../components/ShowLocalNotification.js"; const logger = new Logger("PaytoWireTransferForm"); @@ -82,6 +79,7 @@ export function PaytoWireTransferForm({ const trimmedAmountStr = amount?.trim(); const parsedAmount = Amounts.parse(`${limit.currency}:${trimmedAmountStr}`); const IBAN_REGEX = /^[A-Z][A-Z0-9]*$/; + const [notification, notify, handleError] = useLocalNotification() const errorsWire = undefinedIfEmpty({ iban: !iban @@ -122,7 +120,7 @@ export function PaytoWireTransferForm({ }); async function doSend() { - let payto_uri: string | undefined; + let payto_uri: PaytoString | undefined; let sendingAmount: AmountString | undefined; if (credentials.status !== "loggedIn") return; if (rawPaytoInput) { @@ -141,7 +139,7 @@ export function PaytoWireTransferForm({ } const puri = payto_uri; - await withRuntimeErrorHandling(i18n, async () => { + await handleError(async () => { const res = await api.createTransaction(credentials, { payto_uri: puri, amount: sendingAmount, @@ -367,6 +365,7 @@ export function PaytoWireTransferForm({ <i18n.Translate>Send</i18n.Translate> </button> </div> + <ShowLocalNotification notification={notification} /> </form> </div > ) |