feat: Implement core grid state management with Zustand, define grid data types, and introduce a heatmap cell component.

This commit is contained in:
Michael committed 2026-03-10 12:56:37 +01:00
1 parent b408de4c9c
commit f15fbe69ec
4 files changed
+8 -1

No files matched your search

@@ -145,6 +145,10 @@ export function FloatingSummaryBar() {
</div> </div>
<div className="flex space-x-12 items-center"> <div className="flex space-x-12 items-center">
<Stat
label="Nombre de Produits"
value={summary.totalProducts.toLocaleString("fr-FR")}
/>
<Stat <Stat
label="Volume Total Vendu" label="Volume Total Vendu"
value={Math.round(summary.totalQuantite).toLocaleString("fr-FR")} value={Math.round(summary.totalQuantite).toLocaleString("fr-FR")}
@@ -15,7 +15,7 @@ function getHeatmapClass(value: number | null): string {
export const HeatmapCell = React.memo(({ value }: HeatmapCellProps) => { export const HeatmapCell = React.memo(({ value }: HeatmapCellProps) => {
const heatClass = getHeatmapClass(value); const heatClass = getHeatmapClass(value);
const display = value === null || value === 0 ? "—" : Math.round(Math.abs(value)).toString(); const display = value === null || value === 0 ? "0" : Math.round(Math.abs(value)).toString();
return ( return (
<div <div
@@ -42,6 +42,7 @@ function computeSummary(rows: ProductRow[], drafts: Record<string, GammeCode>):
const totalCa = active.reduce((s, r) => s + (r.totalCa ?? 0), 0); const totalCa = active.reduce((s, r) => s + (r.totalCa ?? 0), 0);
const totalMarge = active.reduce((s, r) => s + (r.totalMarge ?? 0), 0); const totalMarge = active.reduce((s, r) => s + (r.totalMarge ?? 0), 0);
return { return {
totalProducts: rows.length,
totalRows: active.length, totalRows: active.length,
totalQuantite: active.reduce((s, r) => s + (r.totalQuantite ?? 0), 0), totalQuantite: active.reduce((s, r) => s + (r.totalQuantite ?? 0), 0),
totalCa, totalCa,
@@ -65,6 +66,7 @@ export const useGridStore = create<GridState>()(
search: "", search: "",
}, },
summary: { summary: {
totalProducts: 0,
totalRows: 0, totalRows: 0,
totalQuantite: 0, totalQuantite: 0,
totalCa: 0, totalCa: 0,
+1
View File
@@ -70,6 +70,7 @@ export interface ProductRow {
/** Summary bar totals for the currently visible/filtered rows */ /** Summary bar totals for the currently visible/filtered rows */
export interface GridSummary { export interface GridSummary {
totalProducts: number;
totalRows: number; totalRows: number;
totalQuantite: number; totalQuantite: number;
totalCa: number; totalCa: number;