/* This file is part of GNU Taler (C) 2021-2023 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 */ /** * * @author Christian Blättler */ import { useTranslationContext } from "@gnu-taler/web-util/browser"; import { Fragment, h, VNode } from "preact"; import { StateUpdater, useState } from "preact/hooks"; import { format } from "date-fns"; import { MerchantBackend } from "../../../../declaration.js"; import { TalerMerchantApi } from "@gnu-taler/taler-util"; type Entity = TalerMerchantApi.TokenFamilySummary; interface Props { instances: Entity[]; onDelete: (tokenFamily: Entity) => void; onSelect: (tokenFamily: Entity) => void; onUpdate: ( slug: string, data: MerchantBackend.TokenFamilies.TokenFamilyPatchDetail, ) => Promise; onCreate: () => void; selected?: boolean; } export function CardTable({ instances, onCreate, onSelect, onUpdate, onDelete, }: Props): VNode { const [rowSelection, rowSelectionHandler] = useState( undefined, ); const { i18n } = useTranslationContext(); return (

Token Families

{instances.length > 0 ? ( ) : ( )} ); } interface TableProps { rowSelection: string | undefined; instances: Entity[]; onSelect: (tokenFamily: Entity) => void; onUpdate: ( slug: string, data: MerchantBackend.TokenFamilies.TokenFamilyPatchDetail, ) => Promise; onDelete: (tokenFamily: Entity) => void; rowSelectionHandler: StateUpdater; } function Table({ rowSelection, rowSelectionHandler, instances, onSelect, onUpdate, onDelete, }: TableProps): VNode { const { i18n } = useTranslationContext(); return (
{instances.map((i) => { return ( ); })}
Slug Name Valid After Valid Before Kind
rowSelection !== i.slug && rowSelectionHandler(i.slug) } style={{ cursor: "pointer" }} > {i.slug} rowSelection !== i.slug && rowSelectionHandler(i.slug) } style={{ cursor: "pointer" }} > {i.name} rowSelection !== i.slug && rowSelectionHandler(i.slug) } style={{ cursor: "pointer" }} > {i.valid_after.t_s === "never" ? "never" : format(new Date(i.valid_after.t_s * 1000), "yyyy/MM/dd hh:mm:ss")} rowSelection !== i.slug && rowSelectionHandler(i.slug) } style={{ cursor: "pointer" }} > {i.valid_before.t_s === "never" ? "never" : format(new Date(i.valid_before.t_s * 1000), "yyyy/MM/dd hh:mm:ss")} rowSelection !== i.slug && rowSelectionHandler(i.slug) } style={{ cursor: "pointer" }} > {i.kind}
); } function EmptyTable(): VNode { const { i18n } = useTranslationContext(); return (

There are no token families yet, add the first one by pressing the + sign.

); }