/* 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 { HttpStatusCode, TalerError, TalerExchangeApi, assertUnreachable, } from "@gnu-taler/taler-util"; import { Attention, ErrorLoading, InputChoiceHorizontal, Loading, UIHandlerId, useTranslationContext, } from "@gnu-taler/web-util/browser"; import { Fragment, VNode, h } from "preact"; import { useEffect, useState } from "preact/hooks"; import { useCases } from "../hooks/useCases.js"; import { privatePages } from "../Routing.js"; import { FormErrors, RecursivePartial, useFormState } from "../hooks/form.js"; import { undefinedIfEmpty } from "./CreateAccount.js"; import { Officer } from "./Officer.js"; import { amlStateConverter } from "../utils/converter.js"; type FormType = { state: TalerExchangeApi.AmlState; }; export function CasesUI({ records, filter, onChangeFilter, onFirstPage, onNext, }: { onFirstPage?: () => void; onNext?: () => void; filter: TalerExchangeApi.AmlState; onChangeFilter: (f: TalerExchangeApi.AmlState) => void; records: TalerExchangeApi.AmlRecord[]; }): VNode { const { i18n } = useTranslationContext(); const [form, status] = useFormState( [".state"] as Array, { state: filter, }, (state) => { const errors = undefinedIfEmpty>({ state: state.state === undefined ? i18n.str`required` : undefined, }); if (errors === undefined) { const result: FormType = { state: state.state!, }; return { status: "ok", result, errors, }; } const result: RecursivePartial = { state: state.state, }; return { status: "fail", result, errors, }; }, ); useEffect(() => { if (status.status === "ok" && filter !== status.result.state) { onChangeFilter(status.result.state); } }, [form?.state?.value]); return (

Cases

A list of all the account with the status

name="state" label={i18n.str`Filter`} handler={form.state} converter={amlStateConverter} choices={[ { label: i18n.str`Pending`, value: "pending", }, { label: i18n.str`Frozen`, value: "frozen", }, { label: i18n.str`Normal`, value: "normal", }, ]} />
{!records.length ? (
empty result
) : (
{records.map((r) => { return ( ); })}
Account Id Status Threshold
{((state: TalerExchangeApi.AmlState): VNode => { switch (state) { case TalerExchangeApi.AmlState.normal: { return ( Normal ); } case TalerExchangeApi.AmlState.pending: { return ( Pending ); } case TalerExchangeApi.AmlState.frozen: { return ( Frozen ); } } })(r.current_state)} {r.threshold}
)}
); } export function Cases() { const [stateFilter, setStateFilter] = useState( TalerExchangeApi.AmlState.pending, ); const list = useCases(stateFilter); const { i18n } = useTranslationContext(); if (!list) { return ; } if (list instanceof TalerError) { return ; } if (list.type === "fail") { switch (list.case) { case HttpStatusCode.Forbidden: { return ( This account doesnt have access. Request account activation sending your public key. ); } case HttpStatusCode.Unauthorized: { return ( This account is not allowed to perform list the cases. ); } case HttpStatusCode.NotFound: case HttpStatusCode.Conflict: return ; default: assertUnreachable(list); } } return ( { setStateFilter(d); }} /> ); } export const PeopleIcon = () => ( ); export const HomeIcon = () => ( ); function Pagination({ onFirstPage, onNext, }: { onFirstPage?: () => void; onNext?: () => void; }) { const { i18n } = useTranslationContext(); return ( ); }