diff --git a/client/src/pages/InvoicesBAP.tsx b/client/src/pages/InvoicesBAP.tsx index 6810795..397c306 100644 --- a/client/src/pages/InvoicesBAP.tsx +++ b/client/src/pages/InvoicesBAP.tsx @@ -32,7 +32,8 @@ import { TableRow, } from "@/components/ui/table"; import { trpc } from "@/lib/trpc"; -import { Search, FileText, Download, FileSpreadsheet, Trash2, Edit, Trash, CheckCircle, CheckCircle2, ShieldCheck, RefreshCw, FolderDown, ChevronDown, ChevronRight, ChevronsUpDown } from "lucide-react"; +import { Search, FileText, Download, FileSpreadsheet, Trash2, Edit, Trash, CheckCircle, CheckCircle2, ShieldCheck, RefreshCw, FolderDown, ChevronDown, ChevronRight, ChevronsUpDown, CalendarDays } from "lucide-react"; +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; // Helper : télécharge un ZIP de plusieurs PDFs annotés BAP async function downloadBapZip( @@ -124,6 +125,10 @@ export default function InvoicesBAP() { // Accordéon : lignes dépliées const [expandedIds, setExpandedIds] = useState>(new Set()); const [allExpanded, setAllExpanded] = useState(false); + // Filtre par période + const currentYear = new Date().getFullYear(); + const [selectedYear, setSelectedYear] = useState(String(currentYear)); + const [selectedMonth, setSelectedMonth] = useState("all"); // "all" ou "01".."12" const toggleRow = (id: number) => { setExpandedIds(prev => { @@ -354,6 +359,16 @@ export default function InvoicesBAP() { if (!matchesSearch) return false; } + // Filter by period (year + optional month) + if (selectedYear !== "all") { + const invDate = inv.invoiceDate ? new Date(inv.invoiceDate) : null; + const fallbackDate = inv.createdAt ? new Date(inv.createdAt) : null; + const dateToUse = invDate || fallbackDate; + if (!dateToUse) return false; + if (dateToUse.getFullYear() !== parseInt(selectedYear)) return false; + if (selectedMonth !== "all" && (dateToUse.getMonth() + 1) !== parseInt(selectedMonth)) return false; + } + // Filter by export status if (statusFilter !== "all") { if (statusFilter === "exported" && inv.exportStatus !== "exported") return false; @@ -614,8 +629,56 @@ export default function InvoicesBAP() { + {/* Period Filter + Status Filters */} +
+
+ + Période : +
+ {/* Year selector */} + + {/* Month selector — disabled when year = all */} + + {(selectedYear !== "all" || selectedMonth !== "all") && ( + + )} +
+ {/* Status Filters */} -
+