taler-typescript-core

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

commit 77181b9c8ee2c824fc2c59ddd73d1fd4a65295b4
parent 2870dd3778b00bafa78956dada74f1b08ed8711f
Author: Sebastian <sebasjm@taler-systems.com>
Date:   Wed,  8 Apr 2026 19:21:56 -0300

fix #11342

Diffstat:
Mpackages/merchant-backoffice-ui/src/components/exception/QR.tsx | 4++--
Mpackages/merchant-backoffice-ui/src/components/modal/index.tsx | 56++++++++++++++++++++++++--------------------------------
Mpackages/merchant-backoffice-ui/src/hooks/instance.ts | 1+
Mpackages/merchant-backoffice-ui/src/paths/instance/accounts/list/index.tsx | 1+
Mpackages/merchant-backoffice-ui/src/paths/instance/kyc/list/index.tsx | 2+-
Mpackages/web-util/src/hooks/useAsync.ts | 57+++++++++++++++++++++++++++++++++++----------------------
6 files changed, 64 insertions(+), 57 deletions(-)

diff --git a/packages/merchant-backoffice-ui/src/components/exception/QR.tsx b/packages/merchant-backoffice-ui/src/components/exception/QR.tsx @@ -181,7 +181,7 @@ export function QR_TOTP({ otpAuthURI }: { otpAuthURI: string }): VNode { export function QR_SwissBank({ text }: { text: string }): VNode { return ( <QR - style={{ width: "90%", maxWidth: 400, margin: "auto", padding: 10 }} + style={{ width: "90%", maxWidth: 300, margin: "auto", padding: 10 }} text={text} typeNumber={0} // section 6.2 errorCorrectionLevel="M" // section 6.1 @@ -206,7 +206,7 @@ export function QR_Bank({ label: TranslatedString; }): VNode { return ( - <QR style={{ width: "90%", maxWidth: 400, margin: "auto" }} text={text}> + <QR style={{ width: "90%", maxWidth: 300, margin: "auto" }} text={text}> <div style={{ fontWeight: "bold" }}>{label}</div> </QR> ); diff --git a/packages/merchant-backoffice-ui/src/components/modal/index.tsx b/packages/merchant-backoffice-ui/src/components/modal/index.tsx @@ -473,32 +473,23 @@ export function ValidBankAccount({ {qrs.map((q, idx) => { return ( <tr key={idx}> - <td - style={{ - padding: 5, - borderSpacing: 0, - borderRadius: 4, - border: "1px solid black", - }} - > - <Accordion name={q.type} openedByDefault> - {(function () { - switch (q.type) { - case "epc-qr": - return ( - <QR_Bank - text={q.qrContent} - label={i18n.str`Banking app`} - /> - ); - case "spc": - return <QR_SwissBank text={q.qrContent} />; - - default: - assertUnreachable(q.type); - } - })()} - </Accordion> + <td style={{}}> + {(function () { + switch (q.type) { + case "epc-qr": + return ( + <QR_Bank + text={q.qrContent} + label={i18n.str`Banking app`} + /> + ); + case "spc": + return <QR_SwissBank text={q.qrContent} />; + + default: + assertUnreachable(q.type); + } + })()} </td> </tr> ); @@ -565,7 +556,7 @@ export function ValidBankAccount({ that you are choosing the bank account from which you definitely want to make the wire transfer. You can use the copy buttons (<CopyIcon />) to avoid typos or make use of - the "payto://" URI below to copy just one value. + the PayTo URI below to copy just one value. </i18n.Translate> </b> </td> @@ -573,17 +564,18 @@ export function ValidBankAccount({ <tr> <td colSpan={2} width="100%"> <i18n.Translate> - As an alternative, in case that your bank already supports the - 'PayTo URI' standard, you can use this{" "} + As an alternative, in case that your bank already supports the{" "} <a target="_blank" rel="noreferrer" title="RFC 8905 for designating targets for payments" href="https://tools.ietf.org/html/rfc8905" > - PayTo URI - </a>{" "} - link instead + PayTo URI standard + </a> + , you can use this{" "} + <a href={Paytos.toFullString(payto)}>PayTo URI</a> link + instead </i18n.Translate> </td> <td> diff --git a/packages/merchant-backoffice-ui/src/hooks/instance.ts b/packages/merchant-backoffice-ui/src/hooks/instance.ts @@ -28,6 +28,7 @@ import { useSessionContext } from "../context/session.js"; // Fix default import https://github.com/microsoft/TypeScript/issues/49189 import _useSWR, { mutate, SWRHook } from "swr"; +import { useEffect } from "preact/hooks"; const useSWR = _useSWR as unknown as SWRHook; export function revalidateInstanceDetails() { diff --git a/packages/merchant-backoffice-ui/src/paths/instance/accounts/list/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/accounts/list/index.tsx @@ -41,6 +41,7 @@ import { import { LoginPage } from "../../../login/index.js"; import { NotFoundPageOrAdminCreate } from "../../../notfound/index.js"; import { CardTable } from "./Table.js"; +import { useEffect } from "preact/hooks"; const TALER_SCREEN_ID = 34; diff --git a/packages/merchant-backoffice-ui/src/paths/instance/kyc/list/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/kyc/list/index.tsx @@ -59,7 +59,7 @@ export default function ListKYC(_p: Props): VNode { // useEffect(() => { // if (!result || result instanceof TalerError || result.type === "fail") return; // if (!result.body.kyc_data.length) return; - // setShowingInstructions(result.body.kyc_data[0]) + // setShowingInstructions(result.body.kyc_data[1]) // }) if (!result) return <Loading />; if (result instanceof TalerError) { diff --git a/packages/web-util/src/hooks/useAsync.ts b/packages/web-util/src/hooks/useAsync.ts @@ -111,44 +111,58 @@ export function useLongPolling<Res>( ct.current.ct = tk; const doWeRetry = shouldRetryFn(result); - // console.log("should retry", rt !== undefined); if (!doWeRetry) return; const diff = new Date().getTime() - ct.current.startMs; if (ct.current.startMs === 0 || diff > minTime) { ct.current.startMs = new Date().getTime(); - // console.log("starting request", ct.current.ct.token.id); - retryFn(tk.token, result, deps).then((r) => { - if (!tk.token.isCancelled) { - setResult(r); - } - }).catch(error => console.log("")); + retryFn(tk.token, result, deps) + .then((r) => { + if (!tk.token.isCancelled) { + setResult(r); + } + }) + .catch((error) => console.log("")); } else { - // console.log("wait before retry"); // calling too fast, wait whats left to reach minTime delayMs(minTime - diff).then(() => { if (ct.current.unloaded) return; ct.current.startMs = new Date().getTime(); - // console.log( - // "starting request after wait", - // ct.current.ct?.token.id, - // ct.current.unloaded, - // ); - retryFn(tk.token, result, deps).then((r) => { - if (!tk.token.isCancelled) { - setResult(r); - } - }).catch(error => console.log("")); + retryFn(tk.token, result, deps) + .then((r) => { + if (!tk.token.isCancelled) { + setResult(r); + } + }) + .catch((error) => console.log("")); }); } return () => { - // console.log("request unused, cancel", ct.current.ct?.token.id); - tk.cancel(); + }; + }, [result]); + + /** + * the resultset is not needed anymore + */ + useEffect(() => { + return () => { ct.current.unloaded = true; ct.current.startMs = 0; }; - }, [result]); + }, []); + + /** + * request dependency changed + * different resultset expected + */ + useEffect(() => { + return () => { + ct.current.ct?.cancel(); + ct.current.unloaded = true; + ct.current.startMs = 0; + }; + }, deps); return result; } @@ -163,4 +177,3 @@ export async function delayMs(ms: number): Promise<void> { setTimeout(() => resolve(), ms); }); } -