From 072ac43b9f69807b8514eb11f8214637561a2573 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 4 Apr 2024 16:24:55 -0300 Subject: fix some API differences including whatwg-url params --- packages/aml-backoffice-ui/src/pages/Cases.tsx | 398 +++++++++++++++---------- 1 file changed, 237 insertions(+), 161 deletions(-) (limited to 'packages/aml-backoffice-ui/src/pages') diff --git a/packages/aml-backoffice-ui/src/pages/Cases.tsx b/packages/aml-backoffice-ui/src/pages/Cases.tsx index 88580a4ce..faef0ca54 100644 --- a/packages/aml-backoffice-ui/src/pages/Cases.tsx +++ b/packages/aml-backoffice-ui/src/pages/Cases.tsx @@ -1,168 +1,198 @@ -import { HttpStatusCode, TalerError, TalerExchangeApi, TranslatedString, assertUnreachable } from "@gnu-taler/taler-util"; -import { ErrorLoading, Loading, createNewForm, useTranslationContext } from "@gnu-taler/web-util/browser"; +/* + This file is part of GNU Taler + (C) 2022 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 { + HttpStatusCode, + TalerError, + TalerExchangeApi, + assertUnreachable +} from "@gnu-taler/taler-util"; +import { + ErrorLoading, + Loading, + createNewForm, + useTranslationContext, +} from "@gnu-taler/web-util/browser"; import { VNode, h } from "preact"; import { useState } from "preact/hooks"; import { useCases } from "../hooks/useCases.js"; import { Pages } from "../pages.js"; -import { Officer } from "./Officer.js"; import { amlStateConverter } from "../utils/converter.js"; import { AmlExchangeBackend } from "../utils/types.js"; +import { Officer } from "./Officer.js"; -export function CasesUI({ records, filter, onChangeFilter, onFirstPage, onNext }: { onFirstPage?: () => void, onNext?: () => void, filter: AmlExchangeBackend.AmlState, onChangeFilter: (f: AmlExchangeBackend.AmlState) => void, records: TalerExchangeApi.AmlRecord[] }): VNode { +export function CasesUI({ + records, + filter, + onChangeFilter, + onFirstPage, + onNext, +}: { + onFirstPage?: () => void; + onNext?: () => void; + filter: AmlExchangeBackend.AmlState; + onChangeFilter: (f: AmlExchangeBackend.AmlState) => void; + records: TalerExchangeApi.AmlRecord[]; +}): VNode { const { i18n } = useTranslationContext(); const form = createNewForm<{ state: AmlExchangeBackend.AmlState }>(); - return
-
-
-

- - Cases - -

-

- - A list of all the account with the status - -

-
-
- { - onChangeFilter(v.state ?? filter); - }} - onSubmit={(v) => { }} - > - - - + return ( +
+
+
+

+ Cases +

+

+ + A list of all the account with the status + +

+
+
+ { + onChangeFilter(v.state ?? filter); + }} + onSubmit={(_v) => {}} + > + + +
-
-
-
- {!records.length ? ( -
empty result
- ) : ( -
- - - - - - - - - - {records.map((r) => { - return ( - - - + + + ); + })} + +
- - Account Id - - - - Status - - - - Threshold - -
- - - {((state: AmlExchangeBackend.AmlState): VNode => { - switch (state) { - case AmlExchangeBackend.AmlState.normal: { - return ( - - Normal - - ); - } - case AmlExchangeBackend.AmlState.pending: { - return ( - - Pending - - ); +
+
+ {!records.length ? ( +
empty result
+ ) : ( +
+ + + + + + + + + + {records.map((r) => { + return ( + + + - - - ); - })} - -
+ Account Id + + Status + + Threshold +
+ + + {((state: AmlExchangeBackend.AmlState): VNode => { + switch (state) { + case AmlExchangeBackend.AmlState.normal: { + return ( + + Normal + + ); + } + case AmlExchangeBackend.AmlState.pending: { + return ( + + Pending + + ); + } + case AmlExchangeBackend.AmlState.frozen: { + return ( + + Frozen + + ); + } } - case AmlExchangeBackend.AmlState.frozen: { - return ( - - Frozen - - ); - } - } - })(r.current_state)} - - {r.threshold} -
- -
- )} + })(r.current_state)} +
+ {r.threshold} +
+ +
+ )} +
-
- + ); } - export function Cases() { - const [stateFilter, setStateFilter] = useState(AmlExchangeBackend.AmlState.pending); + const [stateFilter, setStateFilter] = useState( + AmlExchangeBackend.AmlState.pending, + ); const list = useCases(stateFilter); if (!list) { - return + return ; } if (list instanceof TalerError) { - return + return ; } if (list.data.type === "fail") { @@ -170,34 +200,81 @@ export function Cases() { case HttpStatusCode.Unauthorized: case HttpStatusCode.Forbidden: case HttpStatusCode.NotFound: - case HttpStatusCode.Conflict: return - default: assertUnreachable(list.data) + case HttpStatusCode.Conflict: + return ; + default: + assertUnreachable(list.data); } } - const { records } = list.data.body + const { records } = list.data.body; - return + return ( + + ); } -export const PeopleIcon = () => - - +export const PeopleIcon = () => ( + + + +); -export const HomeIcon = () => - - +export const HomeIcon = () => ( + + + +); -function Pagination({ onFirstPage, onNext }: { onFirstPage?: () => void, onNext?: () => void, }) { - const { i18n } = useTranslationContext() +function Pagination({ + onFirstPage, + onNext, +}: { + onFirstPage?: () => void; + onNext?: () => void; +}) { + const { i18n } = useTranslationContext(); return ( -