From ca076e5eab10d2d471dd68732a7d8a7ac9f5f6bc Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 13 Nov 2023 15:33:13 -0300 Subject: fix new libeufin api --- .../demobank-ui/src/pages/ShowAccountDetails.tsx | 2 +- packages/demobank-ui/src/pages/admin/AdminHome.tsx | 14 +++--- .../src/pages/business/CreateCashout.tsx | 52 ++++++++++------------ .../src/pages/business/ShowCashoutDetails.tsx | 30 ++++++++++--- 4 files changed, 55 insertions(+), 43 deletions(-) (limited to 'packages/demobank-ui/src/pages') diff --git a/packages/demobank-ui/src/pages/ShowAccountDetails.tsx b/packages/demobank-ui/src/pages/ShowAccountDetails.tsx index 2e00fdbba..a88a90499 100644 --- a/packages/demobank-ui/src/pages/ShowAccountDetails.tsx +++ b/packages/demobank-ui/src/pages/ShowAccountDetails.tsx @@ -58,7 +58,7 @@ export function ShowAccountDetails({ email: submitAccount.contact_data?.email, phone: submitAccount.contact_data?.phone, }), - is_exchange: false, + is_taler_exchange: false, name: submitAccount.name, }); diff --git a/packages/demobank-ui/src/pages/admin/AdminHome.tsx b/packages/demobank-ui/src/pages/admin/AdminHome.tsx index 9bc2ee571..a89b4afca 100644 --- a/packages/demobank-ui/src/pages/admin/AdminHome.tsx +++ b/packages/demobank-ui/src/pages/admin/AdminHome.tsx @@ -124,15 +124,15 @@ function Metrics(): VNode {
- {resp.current.body.type !== "with-cashout" || resp.previous.body.type !== "with-cashout" ? undefined : + {resp.current.body.type !== "with-conversions" || resp.previous.body.type !== "with-conversions" ? undefined :
Cashin
@@ -140,8 +140,8 @@ function Metrics(): VNode { Cashout
@@ -151,8 +151,8 @@ function Metrics(): VNode { Payout
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)); }} /> - { - e.preventDefault(); - form.channel = TanChannel.FILE; - updateForm(structuredClone(form)); - }} - /> { + 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({ -
+ {/*
-
+
*/} {isPending ? (