From 6e02a3852590f39cdd414a1caf89506bcd9dc83a Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 11 Mar 2024 14:57:03 -0300 Subject: obs and cancel request, plus lint --- packages/web-util/src/components/Button.tsx | 36 +++++++++--- packages/web-util/src/components/CopyButton.tsx | 5 +- packages/web-util/src/components/ErrorLoading.tsx | 28 +++++++++ packages/web-util/src/components/Header.tsx | 39 +++++++++++-- .../web-util/src/components/NotificationBanner.tsx | 4 +- packages/web-util/src/components/ToastBanner.tsx | 59 ++++++++++++------- packages/web-util/src/hooks/useNotifications.ts | 68 +++++++++++++++++----- packages/web-util/src/utils/http-impl.sw.ts | 5 +- 8 files changed, 191 insertions(+), 53 deletions(-) (limited to 'packages') diff --git a/packages/web-util/src/components/Button.tsx b/packages/web-util/src/components/Button.tsx index 26b778eec..ea0ea2f38 100644 --- a/packages/web-util/src/components/Button.tsx +++ b/packages/web-util/src/components/Button.tsx @@ -1,8 +1,24 @@ -import { OperationFail, OperationOk, OperationResult, TalerError, TranslatedString } from "@gnu-taler/taler-util"; +/* + This file is part of GNU Taler + (C) 2022-2024 Taler Systems S.A. + + GNU Taler is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + GNU Taler; see the file COPYING. If not, see + */ + +import { AbsoluteTime, OperationFail, OperationOk, OperationResult, TalerError, TranslatedString } from "@gnu-taler/taler-util"; // import { NotificationMessage, notifyInfo } from "@gnu-taler/web-util/browser"; import { Fragment, VNode, h } from "preact"; import { HTMLAttributes, useEffect, useState, useTransition } from "preact/compat"; -import { NotificationMessage, buildRequestErrorMessage, notifyInfo, useTranslationContext } from "../index.browser.js"; +import { NotificationMessage, buildUnifiedRequestErrorMessage, notifyInfo, useTranslationContext } from "../index.browser.js"; // import { useBankCoreApiContext } from "../context/config.js"; // function errorMap>(resp: T, map: (d: T["case"]) => TranslatedString): void { @@ -10,7 +26,7 @@ import { NotificationMessage, buildRequestErrorMessage, notifyInfo, useTranslati export interface ButtonHandler, A, B> { onClick: () => Promise, onNotification: (n: NotificationMessage) => void; - onOperationSuccess: ((result:T extends OperationOk ? T :never) => void) | ((result:T extends OperationOk ? T :never) => TranslatedString | undefined), + onOperationSuccess: ((result: T extends OperationOk ? T : never) => void) | ((result: T extends OperationOk ? T : never) => TranslatedString | undefined), onOperationFail: (d: T extends OperationFail ? T : never) => TranslatedString; onOperationComplete?: () => void; } @@ -33,10 +49,10 @@ export function Button, A, B>({ handler, children, disabled, - onClick:clickEvent, + onClick: clickEvent, ...rest }: Props): VNode { - const {i18n} = useTranslationContext(); + const { i18n } = useTranslationContext(); const [running, setRunning] = useState(false) return } -function Wait():VNode { +function Wait(): VNode { return