From b95cc1876b7263913a3a18df9234fd0122f25cf2 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 5 Apr 2024 18:11:15 -0300 Subject: fix #8655 --- packages/aml-backoffice-ui/src/hooks/useBackend.ts | 72 +++++----------------- 1 file changed, 14 insertions(+), 58 deletions(-) (limited to 'packages/aml-backoffice-ui/src') diff --git a/packages/aml-backoffice-ui/src/hooks/useBackend.ts b/packages/aml-backoffice-ui/src/hooks/useBackend.ts index 0615c9c99..7b55568c8 100644 --- a/packages/aml-backoffice-ui/src/hooks/useBackend.ts +++ b/packages/aml-backoffice-ui/src/hooks/useBackend.ts @@ -1,65 +1,21 @@ -import { canonicalizeBaseUrl } from "@gnu-taler/taler-util"; -import { - HttpResponseOk, - RequestOptions, - useApiContext, -} from "@gnu-taler/web-util/browser"; -import { useCallback } from "preact/hooks"; -import { uiSettings } from "../settings.js"; +/* + This file is part of GNU Taler + (C) 2022 Taler Systems S.A. -interface useBackendType { - request: ( - path: string, - options?: RequestOptions, - ) => Promise>; - fetcher: (args: [string, string]) => Promise>; - paginatedFetcher: ( - args: [string, number, number, string], - ) => Promise>; -} -export function usePublicBackend(): useBackendType { - const { request: requestHandler } = useApiContext(); + 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. - const baseUrl = getInitialBackendBaseURL(); + 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. - const request = useCallback( - function requestImpl( - path: string, - options: RequestOptions = {}, - ): Promise> { - return requestHandler(baseUrl, path, options); - }, - [baseUrl], - ); + You should have received a copy of the GNU General Public License along with + GNU Taler; see the file COPYING. If not, see + */ + import { canonicalizeBaseUrl } from "@gnu-taler/taler-util"; +import { uiSettings } from "../settings.js"; - const fetcher = useCallback( - function fetcherImpl([endpoint, talerAmlOfficerSignature]: [string, string]): Promise> { - return requestHandler(baseUrl, endpoint, { - talerAmlOfficerSignature - }); - }, - [baseUrl], - ); - const paginatedFetcher = useCallback( - function fetcherImpl([endpoint, page, size, talerAmlOfficerSignature]: [ - string, - number, - number, - string, - ]): Promise> { - return requestHandler(baseUrl, endpoint, { - params: { page: page || 1, size }, - talerAmlOfficerSignature, - }); - }, - [baseUrl], - ); - return { - request, - fetcher, - paginatedFetcher, - }; -} export function getInitialBackendBaseURL(): string { const overrideUrl = -- cgit v1.2.3