/* 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, } from "@gnu-taler/taler-util"; import { h, VNode } from "preact"; import { useTranslationContext } from "../context/translation.js"; 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 TransactionItem(props: { tx: Transaction }): VNode { const tx = props.tx; const { i18n } = useTranslationContext(); switch (tx.type) { case TransactionType.Withdrawal: return ( ); case TransactionType.Payment: return ( ); case TransactionType.Refund: return ( ); case TransactionType.Tip: return ( ); case TransactionType.Refresh: return ( ); case TransactionType.Deposit: return ( ); case TransactionType.PeerPullCredit: return ( ); case TransactionType.PeerPullDebit: return ( ); case TransactionType.PeerPushCredit: return ( ); case TransactionType.PeerPushDebit: return ( ); default: { assertUnreachable(tx); } } } function TransactionLayout(props: TransactionLayoutProps): VNode { const { i18n } = useTranslationContext(); return ( {props.iconPath}
{props.title}
{props.subtitle && (
{props.subtitle}
)}
{props.pending && ( {props.pending} )}
); } interface TransactionLayoutProps { debitCreditIndicator: "debit" | "credit" | "unknown"; amount: AmountString | "unknown"; timestamp: AbsoluteTime; title: string; subtitle?: string; id: string; iconPath: string; pending?: string; } interface TransactionAmountProps { debitCreditIndicator: "debit" | "credit" | "unknown"; amount: AmountJson; pending: boolean; } 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.pending && (
PENDING
)}
); }