mirror of
https://github.com/R0m1k3/CollectFlow.git
synced 2026-10-11 17:26:32 +02:00
feat: implement client-side grid with heatmap and associated components for product assortment revision.
This commit is contained in:
1 parent
32164572aa
commit
56b09a438d
2 files changed
+10
-6
No files matched your search
@@ -55,9 +55,11 @@ export function GridClient({ initialRows, nomFournisseur, fournisseurs, magasins
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isMounted) return;
|
if (!isMounted) return;
|
||||||
// Deep clone to avoid mutating the React prop directly across re-renders
|
|
||||||
const rowsCopy = JSON.parse(JSON.stringify(initialRows));
|
// Optimisation : On évite le JSON.parse(JSON.stringify()) qui est très lourd sur 1000 lignes
|
||||||
const scoredRows = computeProductScores(rowsCopy, { seuilAxeFort, bonusParAxe });
|
// On passe directement les initialRows au moteur de score, ou on fait une copie superficielle si nécessaire.
|
||||||
|
// Le moteur de score doit idéalement retourner de nouveaux objets.
|
||||||
|
const scoredRows = computeProductScores([...initialRows], { seuilAxeFort, bonusParAxe });
|
||||||
setRows(scoredRows);
|
setRows(scoredRows);
|
||||||
}, [initialRows, setRows, seuilAxeFort, bonusParAxe, isMounted]);
|
}, [initialRows, setRows, seuilAxeFort, bonusParAxe, isMounted]);
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
"use client";
|
import React from "react";
|
||||||
|
|
||||||
interface HeatmapCellProps {
|
interface HeatmapCellProps {
|
||||||
value: number | null;
|
value: number | null;
|
||||||
@@ -13,7 +13,7 @@ function getHeatmapClass(value: number | null): string {
|
|||||||
return "heatmap-zero";
|
return "heatmap-zero";
|
||||||
}
|
}
|
||||||
|
|
||||||
export function HeatmapCell({ 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 ? "—" : Math.round(Math.abs(value)).toString();
|
||||||
|
|
||||||
@@ -25,4 +25,6 @@ export function HeatmapCell({ value }: HeatmapCellProps) {
|
|||||||
{display}
|
{display}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
});
|
||||||
|
|
||||||
|
HeatmapCell.displayName = "HeatmapCell";
|
||||||
Reference in new issue
Block a user