/* 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 { Fragment, h, VNode } from "preact"; import { useTranslationContext } from "@gnu-taler/web-util/browser"; import { State } from "./index.js"; import { format } from "date-fns"; import { Amounts } from "@gnu-taler/taler-util"; import { RenderAmount } from "../../pages/PaytoWireTransferForm.js"; import { assertUnreachable } from "../Routing.js"; import { Attention } from "../Attention.js"; export function LoadingUriView({ error }: State.LoadingUriError): VNode { const { i18n } = useTranslationContext(); return (
Could not load
); } export function FailedView({ error }: State.Failed) { const { i18n } = useTranslationContext(); switch (error.case) { case "cashout-not-supported": return
{error.detail.hint}
case "account-not-found": return
{error.detail.hint}
default: assertUnreachable(error) } } export function ReadyView({ cashouts, onSelected }: State.Ready): VNode { const { i18n } = useTranslationContext(); 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") 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") const confirmationTime = item.confirmation_time ? item.confirmation_time.t_s === "never" ? i18n.str`never` : format(item.confirmation_time.t_s, "dd/MM/yyyy HH:mm:ss") : "-" return () })} })}
{i18n.str`Created`}
{date}
{creationTime}
{/*
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}
                          
*/}
{/* */}
); // } }