/* 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 { useTranslationContext } from "@gnu-taler/web-util/browser"; import { format } from "date-fns"; import { Fragment, h, VNode } from "preact"; import { useBankCoreApiContext } from "../../context/config.js"; import { RenderAmount } from "../../pages/PaytoWireTransferForm.js"; import { State } from "./index.js"; export function ReadyView({ transactions, onNext, onPrev }: State.Ready): VNode { const { i18n, dateLocale } = useTranslationContext(); const { config } = useBankCoreApiContext(); if (!transactions.length) return
const txByDate = transactions.reduce((prev, cur) => { const d = cur.when.t_ms === "never" ? "" : format(cur.when.t_ms, "dd/MM/yyyy", { locale: dateLocale }) if (!prev[d]) { prev[d] = [] } prev[d].push(cur) return prev }, {} as Record) return (

Latest transactions

{Object.entries(txByDate).map(([date, txs], idx) => { return {txs.map(item => { const time = item.when.t_ms === "never" ? "" : format(item.when.t_ms, "HH:mm:ss", { locale: dateLocale }) return () })} })}
{i18n.str`Date`}
{date}
{time}
Amount
{item.negative ? i18n.str`sent` : i18n.str`received`} {item.amount ? ( ) : ( <{i18n.str`invalid value`}> )}
Counterpart
{item.negative ? i18n.str`to` : i18n.str`from`} {item.counterpart}
                            {item.subject}
                          
); }