/* 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, TalerError, assertUnreachable } from "@gnu-taler/taler-util"; import { Attention, ErrorLoading, Loading, useTranslationContext } from "@gnu-taler/web-util/browser"; import { format } from "date-fns"; import { Fragment, h, VNode } from "preact"; import { RenderAmount } from "../../pages/PaytoWireTransferForm.js"; import { State } from "./index.js"; import { useConversionInfo } from "../../hooks/circuit.js"; import { ErrorLoadingWithDebug } from "../ErrorLoadingWithDebug.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(); const resp = useConversionInfo(); if (!resp) { return } if (resp instanceof TalerError) { return } 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}
{ e.preventDefault(); onSelected(item.id); }} class="relative py-2 pl-2 pr-2 text-sm ">
{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}
                          
*/}
{ e.preventDefault(); onSelected(item.id); }} class="hidden sm:table-cell px-3 py-3.5 text-sm text-gray-500 cursor-pointer">{confirmationTime} { 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 cursor-pointer">{item.status} { 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}
); }