diff --git a/client/src/pages/InvoicesBAP.tsx b/client/src/pages/InvoicesBAP.tsx index d6c2321..221b90b 100644 --- a/client/src/pages/InvoicesBAP.tsx +++ b/client/src/pages/InvoicesBAP.tsx @@ -1,4 +1,4 @@ -import { useState } from "react"; +import React, { useState } from "react"; import DashboardLayout from "@/components/DashboardLayout"; import { Card, CardContent } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; @@ -32,7 +32,7 @@ import { TableRow, } from "@/components/ui/table"; import { trpc } from "@/lib/trpc"; -import { Search, FileText, Download, FileSpreadsheet, Trash2, Edit, Trash, CheckCircle, CheckCircle2, ShieldCheck, RefreshCw, FolderDown } from "lucide-react"; +import { Search, FileText, Download, FileSpreadsheet, Trash2, Edit, Trash, CheckCircle, CheckCircle2, ShieldCheck, RefreshCw, FolderDown, ChevronDown, ChevronRight, ChevronsUpDown } from "lucide-react"; // Helper : télécharge un ZIP de plusieurs PDFs annotés BAP async function downloadBapZip( @@ -121,6 +121,28 @@ export default function InvoicesBAP() { const [textDialogOpen, setTextDialogOpen] = useState(false); const [selectedInvoiceText, setSelectedInvoiceText] = useState(null); const [isZipDownloading, setIsZipDownloading] = useState(false); + // Accordéon : lignes dépliées + const [expandedIds, setExpandedIds] = useState>(new Set()); + const [allExpanded, setAllExpanded] = useState(false); + + const toggleRow = (id: number) => { + setExpandedIds(prev => { + const next = new Set(prev); + if (next.has(id)) next.delete(id); + else next.add(id); + return next; + }); + }; + + const toggleAllRows = () => { + if (allExpanded) { + setExpandedIds(new Set()); + setAllExpanded(false); + } else { + setExpandedIds(new Set((filteredInvoices || []).map(inv => inv.id))); + setAllExpanded(true); + } + }; const { data: allInvoices, isLoading } = trpc.invoices.list.useQuery(); // Filter for BAP invoices only (Abonnement = NON, isSubscription = 0) const invoices = allInvoices?.filter(inv => inv.isSubscription === 0); @@ -653,7 +675,17 @@ export default function InvoicesBAP() { - + + {/* Bouton global +/- */} + + + N° Facture Date Montant - Service - Type achat - Ventilation Score Statut - Actions + Actions {filteredInvoices.map((invoice) => { + const isExpanded = expandedIds.has(invoice.id); return ( - + + + {/* Bouton +/- individuel */} + + + handleSelectOne(invoice.id, checked as boolean)} - /> @@ -702,120 +742,6 @@ export default function InvoicesBAP() { ? `${parseFloat(invoice.totalAmount as string).toFixed(2)} €` : "-"} - - - - - - - - -
{getQualityBadge(invoice.qualityScore)} @@ -913,6 +839,98 @@ export default function InvoicesBAP() {
+ {/* Ligne 2 : détails dépliables (Service, Type achat, Ventilation) */} + {isExpanded && ( + + {/* col +/- vide */} + + {/* col checkbox vide */} + + {/* colspan 6 pour les 3 champs */} + +
+ {/* Service */} +
+ Service : + +
+ {/* Type achat */} +
+ Type achat : + +
+ {/* Ventilation */} +
+ Ventilation : + +
+
+
+
+ )} +
); })}