import { useQuery } from "@tanstack/react-query"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; import { FileText, Home, Gavel, Shield } from "lucide-react"; import { Transaction } from "@/types/blockchain"; interface TransactionListProps { limit?: number; } export function TransactionList({ limit = 10 }: TransactionListProps) { const { data: transactions = [], isLoading } = useQuery({ queryKey: [`/api/blockchain/transactions/recent?limit=${limit}`], refetchInterval: 5000, // Refresh every 5 seconds }); const getTransactionIcon = (type: string) => { switch (type) { case 'evidence': return ; case 'property': return ; case 'case': return ; case 'audit': return ; default: return ; } }; const getTransactionClass = (type: string) => { switch (type) { case 'evidence': return 'tx-evidence'; case 'property': return 'tx-property'; case 'case': return 'tx-case'; case 'audit': return 'tx-audit'; default: return 'tx-evidence'; } }; const getStatusBadge = (status: string) => { switch (status) { case 'confirmed': return Confirmed; case 'pending': return Pending; default: return Unknown; } }; if (isLoading) { return ( Recent Transactions
{[...Array(3)].map((_, i) => (
))}
); } return (
Recent Transactions
{transactions.length === 0 ? (

No recent transactions

) : ( transactions.map((tx: Transaction, index: number) => (
{getTransactionIcon(tx.type)}

{tx.type === 'evidence' && 'Evidence Recorded'} {tx.type === 'property' && 'Property NFT Minted'} {tx.type === 'case' && 'Case Created'} {tx.type === 'audit' && 'Audit Entry'}

{tx.hash ? `${tx.hash.substring(0, 10)}...${tx.hash.substring(tx.hash.length - 4)}` : 'No hash'}

{getStatusBadge(tx.status || 'confirmed')}

{tx.createdAt ? new Date(tx.createdAt).toLocaleTimeString() : 'Just now'}

)) )}
); }