feat: date de derniere entree en stock par magasin dans le tooltip des badges

This commit is contained in:
Michael committed 2026-05-26 15:57:16 +02:00
1 parent 989307bf2f
commit cd7b87aef8
4 files changed
+49 -14

No files matched your search

@@ -303,6 +303,14 @@ async function buildProductRows(input: GetProductRowsInput): Promise<ProductRow[
const dernLiv = sitesStock.reduce<string>((best, r) =>
r.dernierereception && r.dernierereception > best ? r.dernierereception : best, "");
if (dernLiv) product.derniereLivraison = dernLiv;
// Map store-specific delivery dates
product.derniereLivraisonByStore = {};
for (const r of sitesStock) {
if (r.site && r.dernierereception) {
product.derniereLivraisonByStore[r.site] = r.dernierereception;
}
}
}
// ─── Phase 8 : Ranking réseau ────────────────────────────────────────
+13 -1
View File
@@ -48,6 +48,11 @@ function formatMonthLabel(key: string): string {
return `${names[m - 1]} ${key.slice(2, 4)}`;
}
function formatDate(iso?: string): string {
if (!iso) return "—";
return new Date(iso).toLocaleDateString("fr-FR", { day: "2-digit", month: "2-digit", year: "numeric" });
}
/**
* Returns premium styling and color for stores based on the store name's hash.
* This guarantees a consistent color for a given store, regardless of its position in the list.
@@ -458,10 +463,17 @@ export function HeatmapGrid({ onSelectionChange, isAdmin }: HeatmapGridProps) {
<div className="flex gap-1.5 shrink-0">
{r.workingStores.map((magasin) => {
const config = getStoreConfig(magasin);
const lastLivDate = r.derniereLivraisonByStore?.[magasin];
const storeName = SITE_LABELS[magasin]?.nom ?? magasin;
const tooltipTitle = `Magasin : ${storeName}\n${
lastLivDate
? `Dernière entrée en stock : ${formatDate(lastLivDate)}`
: "Aucune entrée enregistrée"
}`;
return (
<div
key={magasin}
title={`Travaillé par : ${SITE_LABELS[magasin]?.nom ?? magasin}`}
title={tooltipTitle}
className="px-1.5 py-0.5 rounded-md flex items-center gap-1 text-[10px] font-black border shadow-sm transition-transform hover:scale-110"
style={{
background: config.bg,
+2
View File
@@ -61,6 +61,8 @@ export interface ProductRow {
stock12mByStore?: Record<string, Record<string, number>>;
/** Per-store reception breakdown (site → YYYYMM → qté reçue) */
receptions12mByStore?: Record<string, Record<string, number>>;
/** Per-store last delivery/reception date (site → ISO date string) */
derniereLivraisonByStore?: Record<string, string>;
/** Per-store CA totals */
caByStore?: Record<string, number>;
/** Per-store quantity totals */