"use client"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; import { CheckCircle2, Circle } from "lucide-react"; import { CategoryIcon } from "@/components/ui/category-icon"; import type { BankingData } from "@/lib/types"; import { cn } from "@/lib/utils"; interface RecentTransactionsProps { data: BankingData; } export function RecentTransactions({ data }: RecentTransactionsProps) { const recentTransactions = [...data.transactions] .sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime()) .slice(0, 10); const formatCurrency = (amount: number) => { return new Intl.NumberFormat("fr-FR", { style: "currency", currency: "EUR", }).format(amount); }; const formatDate = (dateStr: string) => { return new Date(dateStr).toLocaleDateString("fr-FR", { day: "2-digit", month: "short", }); }; const getCategory = (categoryId: string | null) => { if (!categoryId) return null; return data.categories.find((c) => c.id === categoryId); }; const getAccount = (accountId: string) => { return data.accounts.find((a) => a.id === accountId); }; if (recentTransactions.length === 0) { return ( Transactions récentes

Aucune transaction

Importez un fichier OFX pour commencer

); } return ( Transactions récentes
{recentTransactions.map((transaction) => { const category = getCategory(transaction.categoryId); const account = getAccount(transaction.accountId); return (
{transaction.isReconciled ? ( ) : ( )}

{transaction.description}

= 0 ? "text-emerald-600" : "text-red-600", )} > {transaction.amount >= 0 ? "+" : ""} {formatCurrency(transaction.amount)}
{formatDate(transaction.date)} {account && ( • {account.name} )} {category && ( {category.name} )}
); })}
); }