/* 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 */ import { Amounts } from "@gnu-taler/taler-util"; import { h, VNode } from "preact"; import emptyImage from "../../assets/empty.png"; import { useTranslationContext } from "@gnu-taler/web-util/browser"; import { MerchantBackend } from "../../declaration.js"; interface Props { list: MerchantBackend.Product[]; actions?: { name: string; tooltip: string; handler: (d: MerchantBackend.Product, index: number) => void; }[]; } export function ProductList({ list, actions = [] }: Props): VNode { const { i18n } = useTranslationContext(); return (
{list.map((entry, index) => { const unitPrice = !entry.price ? "0" : entry.price; const totalPrice = !entry.price ? "0" : Amounts.stringify( Amounts.mult( Amounts.parseOrThrow(entry.price), entry.quantity, ).amount, ); return ( ); })}
image description quantity unit price total price
{entry.description} {entry.quantity === 0 ? "--" : `${entry.quantity} ${entry.unit}`} {unitPrice} {totalPrice} {actions.map((a, i) => { return (
); })}
); }