/* 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 { AbsoluteTime, Amounts, HttpStatusCode, TalerError, assertUnreachable, } from "@gnu-taler/taler-util"; import { Attention, Loading, useTranslationContext, } from "@gnu-taler/web-util/browser"; import { format } from "date-fns"; import { Fragment, VNode, h } from "preact"; import { useConversionInfo } from "../../hooks/regional.js"; import { RenderAmount } from "../../pages/PaytoWireTransferForm.js"; import { ErrorLoadingWithDebug } from "../ErrorLoadingWithDebug.js"; import { Time } from "../Time.js"; import { State } from "./index.js"; export function FailedView({ error }: State.Failed) { const { i18n } = useTranslationContext(); switch (error.case) { case HttpStatusCode.NotImplemented: { return ( Cashout should be enable by configuration and the conversion rate should be initialized with fee, ratio and rounding mode. ); } default: assertUnreachable(error.case); } } export function ReadyView({ cashouts, routeCashoutDetails, }: State.Ready): VNode { const { i18n, dateLocale } = useTranslationContext(); const resp = useConversionInfo(); if (!resp) { return ; } if (resp instanceof TalerError) { return ; } if (resp.type === "fail") { switch (resp.case) { case HttpStatusCode.NotImplemented: { return ( Cashout should be enable by configuration and the conversion rate should be initialized with fee, ratio and rounding mode. ); } default: assertUnreachable(resp.case); } } if (!cashouts.length) return
; const txByDate = cashouts.reduce( (prev, cur) => { const d = cur.creation_time.t_s === "never" ? "" : format(cur.creation_time.t_s * 1000, "dd/MM/yyyy", { locale: dateLocale, }); if (!prev[d]) { prev[d] = []; } prev[d].push(cur); return prev; }, {} as Record, ); return (

Latest cashouts

{Object.entries(txByDate).map(([date, txs], idx) => { return ( {txs.map((item) => { return ( ); })} ); })}
{i18n.str`Created`}
{date}
{ //FIXME: implement responsive view } {/*
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}
                          
*/}
); }