taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 9e12df9f907752b61d14d425b3136b0c577bb95c
parent f6ee01b08b23b3a3c4d74b3249cd84f9731e1463
Author: Sebastian <sebasjm@taler-systems.com>
Date:   Wed, 11 Feb 2026 16:30:05 -0300

fix #11051

Diffstat:
Mpackages/bank-ui/src/hooks/regional.ts | 10++++------
Mpackages/bank-ui/src/pages/regional/CreateCashout.tsx | 6++++--
Mpackages/web-util/src/components/NotificationBanner.tsx | 42++++++++++++++++++++++++++++++++++++++----
Mpackages/web-util/src/hooks/useNotifications.ts | 4++--
4 files changed, 48 insertions(+), 14 deletions(-)

diff --git a/packages/bank-ui/src/hooks/regional.ts b/packages/bank-ui/src/hooks/regional.ts @@ -21,24 +21,22 @@ import { AccessToken, AmountJson, Amounts, - HttpStatusCode, OperationOk, + TalerBankConversionErrorsByMethod, + TalerBankConversionHttpClient, TalerBankConversionResultByMethod, TalerCoreBankErrorsByMethod, TalerCoreBankResultByMethod, TalerCorebankApi, - TalerError, TalerHttpError, - opFixedSuccess, + assertUnreachable, + opFixedSuccess } from "@gnu-taler/taler-util"; import { useBankCoreApiContext } from "@gnu-taler/web-util/browser"; import { useState } from "preact/hooks"; import _useSWR, { SWRHook, mutate } from "swr"; import { PAGINATED_LIST_REQUEST } from "../utils.js"; import { buildPaginatedResult } from "./account.js"; -import { TalerBankConversionHttpClient } from "@gnu-taler/taler-util"; -import { assertUnreachable } from "@gnu-taler/taler-util"; -import { TalerBankConversionErrorsByMethod } from "@gnu-taler/taler-util"; // FIX default import https://github.com/microsoft/TypeScript/issues/49189 const useSWR = _useSWR as unknown as SWRHook; diff --git a/packages/bank-ui/src/pages/regional/CreateCashout.tsx b/packages/bank-ui/src/pages/regional/CreateCashout.tsx @@ -186,6 +186,7 @@ export function CreateCashout({ return ( <CreateCashoutInternal accountData={resultAccount.body} + account={accountName} onCashout={onCashout} routeClose={routeClose} focus={focus} @@ -198,6 +199,7 @@ export function CreateCashout({ function CreateCashoutInternal({ onCashout, + account: accountName, accountData, focus, routeClose, @@ -209,7 +211,7 @@ function CreateCashoutInternal({ }, session, rate, -}: Omit<Props, "account"> & { +}: Props & { convConfig: TalerConversionInfoConfig; rate: ConversionRate; session: LoggedIn; @@ -218,7 +220,7 @@ function CreateCashoutInternal({ const { estimateByCredit: calculateFromCredit, estimateByDebit: calculateFromDebit, - } = useCashoutEstimatorByUser(accountData.name); + } = useCashoutEstimatorByUser(accountName); const [form, setForm] = useState<Partial<FormType>>({ isDebit: true }); const [notification, safeFunctionHandler] = useLocalNotificationBetter(); diff --git a/packages/web-util/src/components/NotificationBanner.tsx b/packages/web-util/src/components/NotificationBanner.tsx @@ -13,9 +13,13 @@ export function LocalNotificationBanner({ }: { notification?: Notification; }): VNode { + const { i18n } = useTranslationContext(); + const [{ showDebugInfo }, update] = useCommonPreferences(); + const [moreInfo, setMoreInfo] = useState(false); if (!notification) return <Fragment />; switch (notification.message.type) { case "error": + const desc = notification.message.description; return ( <div class="relative"> <div class="fixed top-0 left-0 right-0 z-20 w-full p-4"> @@ -26,12 +30,42 @@ export function LocalNotificationBanner({ notification.acknowledge(); }} > - {notification.message.description && ( - <div class="mt-2 text-sm text-red-700"> - {notification.message.description} + {desc && + desc.length && + (moreInfo ? ( + desc.map((d) => { + return <div class="mt-2 text-sm text-red-700">{d}</div>; + }) + ) : ( + <div class="mt-2 text-sm text-red-700">{desc[0]}</div> + ))} + + <div class="flex justify-between"> + <div class="text-[grey]"> + {moreInfo ? undefined : ( + <button onClick={() => setMoreInfo(true)} class="text-grey"> + <i18n.Translate>Show more info</i18n.Translate> + </button> + )} + </div> + + <div class="text-[grey]"> + <button + onClick={() => update("showDebugInfo", !showDebugInfo)} + > + {!showDebugInfo ? ( + <i18n.Translate>Show debug info</i18n.Translate> + ) : ( + <i18n.Translate>Hide debug info</i18n.Translate> + )} + </button> </div> + </div> + {showDebugInfo && ( + <pre class="whitespace-break-spaces text-black"> + {JSON.stringify(notification.message.debug, undefined, 2)} + </pre> )} - <DebugInfo error={notification.message.debug} /> </Attention> </div> </div> diff --git a/packages/web-util/src/hooks/useNotifications.ts b/packages/web-util/src/hooks/useNotifications.ts @@ -312,7 +312,7 @@ function describeErrorResponse( case TalerErrorCode.GENERIC_JSON_INVALID: return i18n.str`Looks like the JSON in the request was malformed.`; default: - return errorResponse.hint as TranslatedString | undefined; + return undefined; } } @@ -399,7 +399,7 @@ function translateTalerError( ? cause.errorDetail.errorResponse.hint : undefined; return [ - i18n.str`The server's response was unexpected. This mean the client and the server are not on sync about the protocol.`, + i18n.str`The server's response was unexpected. This mean the client and the server are not in sync about the protocol.`, i18n.str`The ${cause.errorDetail.requestMethod} request to ${cause.errorDetail.requestUrl} failed with code ${cause.errorDetail.httpStatusCode}`, cause.errorDetail.when ? i18n.str`The request was made at ${AbsoluteTime.stringify(