import type { Transaction } from '@family-budget/shared'; import { formatAmount, formatDateTime } from '../utils/format'; interface Props { transactions: Transaction[]; loading: boolean; onEdit: (tx: Transaction) => void; } const DIRECTION_CLASSES: Record = { income: 'amount-income', expense: 'amount-expense', transfer: 'amount-transfer', }; function TransactionCard({ tx, onEdit, }: { tx: Transaction; onEdit: (tx: Transaction) => void; }) { const directionClass = DIRECTION_CLASSES[tx.direction] ?? ''; const isUnconfirmed = !tx.isCategoryConfirmed && tx.categoryId != null; return (
{formatDateTime(tx.operationAt)} {formatAmount(tx.amountSigned)}
{tx.description} {tx.comment && ( )}
{tx.accountAlias || '—'} · {tx.categoryName || '—'}
{tx.categoryId != null && !tx.isCategoryConfirmed && ( ? )}
); } export function TransactionTable({ transactions, loading, onEdit }: Props) { if (loading) { return
Загрузка операций...
; } if (transactions.length === 0) { return
Операции не найдены
; } return ( <>
{transactions.map((tx) => ( ))}
Дата Счёт Сумма Описание Категория Статус
{formatDateTime(tx.operationAt)} {tx.accountAlias || '—'} {formatAmount(tx.amountSigned)} {tx.description} {tx.comment && ( )} {tx.categoryName || ( )} {tx.categoryId != null && !tx.isCategoryConfirmed && ( ? )}
{transactions.map((tx) => ( ))}
); }