import { Loader2, History, ArrowUpRight, ArrowDownLeft, Zap, Coins } from 'lucide-react';
import type { HistoryEntry } from 'coco-cashu-core';
interface TransactionHistoryProps {
entries: HistoryEntry[];
isLoading: boolean;
}
export function TransactionHistory({ entries, isLoading }: TransactionHistoryProps) {
// Icon indicating transaction type (Lightning vs Cashu)
const getTransactionTypeIcon = (type: string) => {
switch (type) {
case 'mint':
case 'melt':
return ;
case 'send':
case 'receive':
return ;
default:
return ;
}
};
// Arrow indicating direction (next to amount)
const getDirectionIcon = (type: string) => {
switch (type) {
case 'mint':
case 'receive':
return ;
case 'melt':
case 'send':
return ;
default:
return null;
}
};
const getHistoryLabel = (type: string) => {
switch (type) {
case 'mint':
case 'receive':
return 'Received';
case 'melt':
case 'send':
return 'Sent';
default:
return type;
}
};
return (
{isLoading ? (
Loading history...
) : entries.length === 0 ? (
No transactions yet
) : (
<>
{entries.map((entry) => (
{getTransactionTypeIcon(entry.type)}
{getHistoryLabel(entry.type)}
{new URL(entry.mintUrl).hostname}
{new Date(entry.createdAt).toLocaleString()}
{entry.type === 'send' || entry.type === 'melt' ? '-' : '+'}
{entry.amount.toLocaleString()} {entry.unit}
{entry.type === 'melt' && (
+ fees
)}
{getDirectionIcon(entry.type)}
))}
>
)}
);
}