From 788bf960060100c1caf94077d4d999e2922682e5 Mon Sep 17 00:00:00 2001 From: Michael SCHAL Date: Tue, 7 Apr 2026 08:21:22 +0200 Subject: [PATCH] feat: implement grid feature with server-side data fetching and product analytics dashboard --- src/app/(dashboard)/hit-parade/client.tsx | 94 ++++++++++++----------- 1 file changed, 48 insertions(+), 46 deletions(-) diff --git a/src/app/(dashboard)/hit-parade/client.tsx b/src/app/(dashboard)/hit-parade/client.tsx index 336dcc8..5e5bd03 100644 --- a/src/app/(dashboard)/hit-parade/client.tsx +++ b/src/app/(dashboard)/hit-parade/client.tsx @@ -87,16 +87,18 @@ export function HitParadeClient({ dateDebut, dateFin, pivotted }: Props) { { qte292: 0, ca292: 0, marge292: 0, qte579: 0, ca579: 0, marge579: 0, qteTotal: 0, caTotal: 0, margeTotal: 0, stock292: 0, stock579: 0, stockTotal: 0 } ), [sorted]); - function ColHeader({ label, sortable, k }: { label: string; sortable?: SortKey; k: string }) { + function ColHeader({ label, sortable, k, group }: { label: string; sortable?: SortKey; k: string; group?: "292" | "579" | "total" }) { const isActive = sortable && sortKey === sortable; + const groupBg = group === "292" ? "bg-blue-50" : group === "579" ? "bg-violet-50" : group === "total" ? "bg-emerald-50" : ""; + const activeBg = group === "292" ? "bg-blue-100 text-blue-700" : group === "579" ? "bg-violet-100 text-violet-700" : group === "total" ? "bg-emerald-100 text-emerald-700" : "bg-blue-50 text-blue-700"; return ( handleSort(sortable) : undefined} className={[ - "px-4 py-2 text-right text-xs font-semibold whitespace-nowrap select-none", - sortable ? "cursor-pointer hover:bg-blue-50" : "", - isActive ? "bg-blue-50 text-blue-700" : "text-gray-600", + "px-4 py-2 text-center text-xs font-semibold whitespace-nowrap select-none", + sortable ? "cursor-pointer" : "", + isActive ? activeBg : `${groupBg} text-gray-600`, ].join(" ")} > {label} @@ -192,82 +194,82 @@ export function HitParadeClient({ dateDebut, dateFin, pivotted }: Props) { - - - % Marge - - - - % Marge - - - - % Marge - + + + % Marge + + + + % Marge + + + + % Marge + {sorted.map((row, idx) => ( - - {row.codein} - {row.libelle.trim()} - {row.fournisseur} - + + {row.codein} + {row.libelle.trim()} + {row.fournisseur} + {row.qte292 > 0 ? formatQte(row.qte292) : —} - + {row.ca292 > 0 ? formatCA(row.ca292) : —} - + {row.ca292 > 0 ? formatPct(row.ca292, row.marge292) : ""} - + {row.stock292 > 0 ? formatQte(row.stock292) : —} - + {row.qte579 > 0 ? formatQte(row.qte579) : —} - + {row.ca579 > 0 ? formatCA(row.ca579) : —} - + {row.ca579 > 0 ? formatPct(row.ca579, row.marge579) : ""} - + {row.stock579 > 0 ? formatQte(row.stock579) : —} - + {row.qteTotal > 0 ? formatQte(row.qteTotal) : —} - + {row.caTotal > 0 ? formatCA(row.caTotal) : —} - + {row.caTotal > 0 ? formatPct(row.caTotal, row.margeTotal) : ""} - + {row.stockTotal > 0 ? formatQte(row.stockTotal) : 0} ))} - - + + TOTAL — {sorted.length} articles - {formatQte(totals.qte292)} - {formatCA(totals.ca292)} - {formatPct(totals.ca292, totals.marge292)} - {formatQte(totals.stock292)} - {formatQte(totals.qte579)} - {formatCA(totals.ca579)} - {formatPct(totals.ca579, totals.marge579)} - {formatQte(totals.stock579)} - {formatQte(totals.qteTotal)} - {formatCA(totals.caTotal)} - {formatPct(totals.caTotal, totals.margeTotal)} - {formatQte(totals.stockTotal)} + {formatQte(totals.qte292)} + {formatCA(totals.ca292)} + {formatPct(totals.ca292, totals.marge292)} + {formatQte(totals.stock292)} + {formatQte(totals.qte579)} + {formatCA(totals.ca579)} + {formatPct(totals.ca579, totals.marge579)} + {formatQte(totals.stock579)} + {formatQte(totals.qteTotal)} + {formatCA(totals.caTotal)} + {formatPct(totals.caTotal, totals.margeTotal)} + {formatQte(totals.stockTotal)}