/* 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 { AmountJson, Amounts, AmountString, AbsoluteTime, Transaction, TransactionType, WithdrawalType, TransactionMajorState, DenomLossEventType, parsePaytoUri, } from "@gnu-taler/taler-util"; import { h, VNode } from "preact"; import { useTranslationContext } from "@gnu-taler/web-util/browser"; import { Avatar } from "../mui/Avatar.js"; import { Pages } from "../NavigationBar.js"; import { assertUnreachable } from "../utils/index.js"; import { Column, ExtraLargeText, HistoryRow, LargeText, LightText, SmallLightText, } from "./styled/index.js"; import { Time } from "./Time.js"; export function HistoryItem(props: { tx: Transaction }): VNode { const tx = props.tx; const { i18n } = useTranslationContext(); /** * */ switch (tx.type) { case TransactionType.Withdrawal: return ( ); case TransactionType.InternalWithdrawal: return ( ); case TransactionType.Payment: return ( ); case TransactionType.Refund: return ( ); case TransactionType.Refresh: return ( ); case TransactionType.Deposit:{ const payto = parsePaytoUri(tx.targetPaytoUri); const title = payto === undefined || !payto.isKnown ? tx.targetPaytoUri : payto.params["receiver-name"] ; return ( ); } case TransactionType.PeerPullCredit: return ( ); case TransactionType.PeerPullDebit: return ( ); case TransactionType.PeerPushCredit: return ( ); case TransactionType.PeerPushDebit: return ( ); case TransactionType.DenomLoss: { switch (tx.lossEventType) { case DenomLossEventType.DenomExpired: { return ( ); } case DenomLossEventType.DenomVanished: { return ( ); } case DenomLossEventType.DenomUnoffered: { return ( ); } default: { assertUnreachable(tx.lossEventType); } } break; } case TransactionType.Recoup: throw Error("recoup transaction not implemented"); default: { assertUnreachable(tx); } } } function Layout(props: LayoutProps): VNode { const { i18n } = useTranslationContext(); return ( {props.iconPath}
{props.title}
{props.subtitle && (
{props.subtitle}
)}
{props.description && ( {props.description} )}
); } interface LayoutProps { debitCreditIndicator: "debit" | "credit" | "unknown"; amount: AmountString | "unknown"; timestamp: AbsoluteTime; title: string; subtitle?: string; id: string; iconPath: string; currentState: TransactionMajorState; description?: string; } interface TransactionAmountProps { debitCreditIndicator: "debit" | "credit" | "unknown"; amount: AmountJson; currentState: TransactionMajorState; } function TransactionAmount(props: TransactionAmountProps): VNode { const { i18n } = useTranslationContext(); let sign: string; switch (props.debitCreditIndicator) { case "credit": sign = "+"; break; case "debit": sign = "-"; break; case "unknown": sign = ""; } return ( {sign} {Amounts.stringifyValue(props.amount, 2)} {props.currentState === TransactionMajorState.Aborted ? (
ABORTED
) : props.currentState === TransactionMajorState.Failed ? (
FAILED
) : undefined}
); }