- {/* Table header */}
+ {/* ── Header strip ── */}
- {sortKey === "ca" && }
- {sortKey === "qte" && }
- {sortKey === "marge" && }
+ {sortKey === "ca" && }
+ {sortKey === "qte" && }
+ {sortKey === "marge" && }
-
+
{title}
+ {/* column labels */}
+
+ {sortKey === "ca" && (
+ <>
+ QTÉ
+ CA
+ >
+ )}
+ {sortKey === "qte" && (
+ QTÉ
+ )}
+ {sortKey === "marge" && (
+ MARGE
+ )}
+
- {items.length === 0 ? (
-
- Aucune donnée
-
- ) : (
- items.map((item, i) => {
- const val = item[sortKey];
- const barPct = maxVal > 0 ? Math.max((val / maxVal) * 100, 2) : 0;
- const txMarge = item.ca > 0 ? (item.marge / item.ca) * 100 : 0;
- const isTopThree = i < 3;
+ {/* ── Rows ── */}
+ {items.length === 0 ? (
+
+ Aucune donnée
+
+ ) : (
+ items.map((item, i) => {
+ const txMarge = item.ca > 0 ? (item.marge / item.ca) * 100 : 0;
+ const margeColor = txMarge > 25 ? "#22c55e" : txMarge > 15 ? "#f59e0b" : "var(--text-muted)";
+ const margeBg = txMarge > 25 ? "rgba(34,197,94,0.1)" : txMarge > 15 ? "rgba(245,158,11,0.1)" : "rgba(100,116,139,0.1)";
+ const margeBorder = txMarge > 25 ? "rgba(34,197,94,0.25)" : txMarge > 15 ? "rgba(245,158,11,0.25)" : "rgba(100,116,139,0.18)";
+ const isEven = i % 2 === 0;
+ const isTopThree = i < 3;
- return (
-
- {/* Main row */}
-
-
-
- {item.libelle1 ?? item.codein}
-
-
- {sortKey === "qte" ? fmtQte(val) : fmtEur(val)}
-
-
+ return (
+
+ {/* ── Primary row: rank + name + main value ── */}
+
+
- {/* Progress bar + meta */}
-
-
-
- {sortKey === "ca" && `${fmtQte(item.qte)} pcs · `}
- {sortKey !== "ca" && `CA ${fmtEur(item.ca)} · `}
- 25 ? "#22c55e" : txMarge > 15 ? "#f59e0b" : "var(--text-muted)" }}>
- {fmtPct(txMarge, false)} mg
-
-
-
+ textOverflow: "ellipsis",
+ whiteSpace: "nowrap",
+ minWidth: 0,
+ lineHeight: 1.3,
+ }}
+ >
+ {item.libelle1 ?? item.codein}
+
+
+ {/* Main sort-key value */}
+
+ {sortKey === "qte"
+ ? `${fmtQte(item.qte)} pcs`
+ : sortKey === "marge"
+ ? fmtEur(item.marge)
+ : fmtEur(item.ca)}
+
- );
- })
- )}
-
+
+ {/* ── Secondary info row ── */}
+
+ {/* For CA table: show qte + marge */}
+ {sortKey === "ca" && (
+ <>
+
+ {fmtQte(item.qte)} pcs
+
+ │
+
+ mg {fmtEur(item.marge)}
+
+ >
+ )}
+
+ {/* For QTE table: show CA + marge */}
+ {sortKey === "qte" && (
+ <>
+
+ CA {fmtEur(item.ca)}
+
+ │
+
+ mg {fmtEur(item.marge)}
+
+ >
+ )}
+
+ {/* For Marge table: show CA + qte */}
+ {sortKey === "marge" && (
+ <>
+
+ CA {fmtEur(item.ca)}
+
+ │
+
+ {fmtQte(item.qte)} pcs
+
+ >
+ )}
+
+ {/* Taux de marge pill — always shown */}
+
+ {fmtPct(txMarge, false)}
+
+
+
+ );
+ })
+ )}
);
}
@@ -494,32 +595,101 @@ function SiteHitParade({ siteData, dateHier }: { siteData: DashboardSiteTop10; d
const name = SITE_NAMES[siteData.site] ?? siteData.site;
return (
-