import DashboardLayout from "@/components/DashboardLayout"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table"; import { Badge } from "@/components/ui/badge"; import { trpc } from "@/lib/trpc"; import { History as HistoryIcon, FileText, Trash2 } from "lucide-react"; import { Button } from "@/components/ui/button"; import { toast } from "sonner"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "@/components/ui/alert-dialog"; export default function History() { const { data: logs, isLoading } = trpc.importLogs.getByUser.useQuery(); const deleteAllMutation = trpc.importLogs.deleteAll.useMutation(); const utils = trpc.useUtils(); const handleDeleteAll = async () => { try { await deleteAllMutation.mutateAsync(); await utils.importLogs.getByUser.invalidate(); toast.success("Logs supprimés", { description: "Tous les logs d'import ont été supprimés avec succès.", }); } catch (error) { toast.error("Erreur", { description: "Impossible de supprimer les logs d'import.", }); } }; return (

Historique des imports

Consultez l'historique de tous vos imports de factures

{logs && logs.length > 0 && ( Êtes-vous sûr ? Cette action supprimera définitivement tous les logs d'import. Cette opération est irréversible. Annuler {deleteAllMutation.isPending ? "Suppression..." : "Supprimer"} )}
Logs d'import Détails de chaque import avec statistiques {isLoading ? (
Chargement...
) : logs && logs.length > 0 ? ( Fichier Date Détectées Importées Doublons Erreurs {logs.map((log) => ( {log.fileName} {new Date(log.importedAt).toLocaleString("fr-FR")} {log.totalInvoicesDetected} {log.invoicesImported} {log.duplicatesIgnored > 0 ? ( {log.duplicatesIgnored} ) : ( - )} {log.errors > 0 ? ( {log.errors} ) : ( - )} ))}
) : (

Aucun historique d'import

)}
); }