/* This file is part of GNU Taler (C) 2022 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, 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/circuit.js"; import { RenderAmount } from "../../pages/PaytoWireTransferForm.js"; import { ErrorLoadingWithDebug } from "../ErrorLoadingWithDebug.js"; import { State } from "./index.js"; export function FailedView({ error }: State.Failed) { const { i18n } = useTranslationContext(); switch (error.case) { case HttpStatusCode.NotImplemented: return
{error.detail.hint}
case HttpStatusCode.NotImplemented: { return ; } default: assertUnreachable(error.case) } } export function ReadyView({ cashouts, onSelected }: 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 ; } 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 => { const creationTime = item.creation_time.t_s === "never" ? "" : format(item.creation_time.t_s * 1000, "HH:mm:ss", { locale: dateLocale }) return () })} })}
{i18n.str`Created`}
{date}
{ e.preventDefault(); onSelected(item.id); }} class="relative py-2 pl-2 pr-2 text-sm ">
{creationTime}
{//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}
                          
*/}
{ e.preventDefault(); onSelected(item.id); }} class="hidden sm:table-cell px-3 py-3.5 text-sm text-red-600 cursor-pointer"> { e.preventDefault(); onSelected(item.id); }} class="hidden sm:table-cell px-3 py-3.5 text-sm text-green-600 cursor-pointer"> { e.preventDefault(); onSelected(item.id); }} class="hidden sm:table-cell px-3 py-3.5 text-sm text-gray-500 break-all min-w-md"> {item.subject}
); }