diff options
Diffstat (limited to 'packages/demobank-ui/src/pages/business')
-rw-r--r-- | packages/demobank-ui/src/pages/business/CreateCashout.tsx | 52 | ||||
-rw-r--r-- | packages/demobank-ui/src/pages/business/ShowCashoutDetails.tsx | 30 |
2 files changed, 47 insertions, 35 deletions
diff --git a/packages/demobank-ui/src/pages/business/CreateCashout.tsx b/packages/demobank-ui/src/pages/business/CreateCashout.tsx index 10be5ec11..525a170bc 100644 --- a/packages/demobank-ui/src/pages/business/CreateCashout.tsx +++ b/packages/demobank-ui/src/pages/business/CreateCashout.tsx @@ -16,19 +16,22 @@ import { Amounts, TalerError, - TranslatedString + TranslatedString, + encodeCrock, + getRandomBytes } from "@gnu-taler/taler-util"; import { + Attention, + ErrorLoading, + Loading, + LocalNotificationBanner, + ShowInputErrorLabel, useLocalNotification, useTranslationContext } from "@gnu-taler/web-util/browser"; import { Fragment, VNode, h } from "preact"; import { useEffect, useState } from "preact/hooks"; import { mutate } from "swr"; -import { Attention } from "@gnu-taler/web-util/browser"; -import { ErrorLoading } from "@gnu-taler/web-util/browser"; -import { Loading } from "@gnu-taler/web-util/browser"; -import { ShowInputErrorLabel } from "@gnu-taler/web-util/browser"; import { useBankCoreApiContext } from "../../context/config.js"; import { useAccountDetails } from "../../hooks/access.js"; import { useBackendState } from "../../hooks/backend.js"; @@ -37,13 +40,11 @@ import { } from "../../hooks/circuit.js"; import { TanChannel, - undefinedIfEmpty, - withRuntimeErrorHandling + undefinedIfEmpty } from "../../utils.js"; import { LoginForm } from "../LoginForm.js"; import { InputAmount } from "../PaytoWireTransferForm.js"; import { assertUnreachable } from "../WithdrawalOperationPage.js"; -import { LocalNotificationBanner } from "@gnu-taler/web-util/browser"; interface Props { account: string; @@ -321,21 +322,6 @@ export function CreateCashout({ updateForm(structuredClone(form)); }} /> - <input - class={ - "pure-button content " + - (form.channel === TanChannel.FILE - ? "pure-button-primary" - : "pure-button-secondary") - } - type="submit" - value={i18n.str`FILE`} - onClick={async (e) => { - e.preventDefault(); - form.channel = TanChannel.FILE; - updateForm(structuredClone(form)); - }} - /> </div> <ShowInputErrorLabel message={errors?.channel} @@ -363,7 +349,9 @@ export function CreateCashout({ if (errors || !creds) return; await handleError(async () => { + const request_uid = encodeCrock(getRandomBytes(16)) const resp = await api.createCashout(creds, { + request_uid, amount_credit: Amounts.stringify(calc.credit), amount_debit: Amounts.stringify(calc.debit), subject: form.subject, @@ -404,12 +392,18 @@ export function CreateCashout({ description: resp.detail.hint as TranslatedString, debug: resp.detail, }); - // case "": return notify({ - // type: "error", - // title: i18n.str`This user is not allowed to make a cashout`, - // description: resp.detail.hint as TranslatedString, - // debug: resp.detail, - // }); + case "request-already-used": return notify({ + type: "error", + title: i18n.str`Duplicated request found, try again.`, + description: resp.detail.hint as TranslatedString, + debug: resp.detail, + }); + case "tan-failed": return notify({ + type: "error", + title: i18n.str`Server couldn't send the confirmation request.`, + description: resp.detail.hint as TranslatedString, + debug: resp.detail, + }); default: assertUnreachable(resp) } } diff --git a/packages/demobank-ui/src/pages/business/ShowCashoutDetails.tsx b/packages/demobank-ui/src/pages/business/ShowCashoutDetails.tsx index 4646e9220..ddfc18a0c 100644 --- a/packages/demobank-ui/src/pages/business/ShowCashoutDetails.tsx +++ b/packages/demobank-ui/src/pages/business/ShowCashoutDetails.tsx @@ -121,12 +121,12 @@ export function ShowCashoutDetails({ </label> <input readOnly value={result.body.status} /> </fieldset> - <fieldset> + {/* <fieldset> <label> <i18n.Translate>Destination</i18n.Translate> </label> <input readOnly value={result.body.credit_payto_uri} /> - </fieldset> + </fieldset> */} {isPending ? ( <fieldset> <label> @@ -220,15 +220,33 @@ export function ShowCashoutDetails({ description: resp.detail.hint as TranslatedString, debug: resp.detail, }) - case "wrong-tan-or-credential": return notify({ + case "no-enough-balance": return notify({ + type: "error", + title: i18n.str`The account does not have sufficient funds`, + description: resp.detail.hint as TranslatedString, + debug: resp.detail, + }); + case "incorrect-exchange-rate": return notify({ + type: "error", + title: i18n.str`The exchange rate was incorrectly applied`, + description: resp.detail.hint as TranslatedString, + debug: resp.detail, + }); + case "already-aborted": return notify({ + type: "error", + title: i18n.str`The cashout operation is already aborted.`, + description: resp.detail.hint as TranslatedString, + debug: resp.detail, + }); + case "no-cashout-payto": return notify({ type: "error", - title: i18n.str`Invalid code or credentials.`, + title: i18n.str`Missing destination account.`, description: resp.detail.hint as TranslatedString, debug: resp.detail, }) - case "cashout-address-changed": return notify({ + case "too-many-attempts": return notify({ type: "error", - title: i18n.str`The cash-out address between the creation and the confirmation changed.`, + title: i18n.str`Too many failed attempts.`, description: resp.detail.hint as TranslatedString, debug: resp.detail, }) |