mirror of
https://github.com/R0m1k3/CollectFlow.git
synced 2026-10-14 02:37:55 +02:00
feat(ai): performance-first logic with store awareness extrapolation and change count fix
This commit is contained in:
1 parent
c5cacd9b5a
commit
259fb60638
3 files changed
+33
-16
No files matched your search
@@ -58,7 +58,8 @@ export function BulkAiAnalyzer() {
|
||||
marge: r.totalMarge ? parseFloat(((r.totalMarge / (r.totalCa || 1)) * 100).toFixed(1)) : 0,
|
||||
score: r.score || 0,
|
||||
codeGamme: r.codeGamme || "N/A",
|
||||
sales12m: r.sales12m || {}, // Send raw object for better AI analysis
|
||||
sales12m: r.sales12m || {},
|
||||
storeCount: r.workingStores?.length || 1,
|
||||
nomenclature: `${r.libelleNiveau1 || ""} > ${r.libelleNiveau2 || ""} > ${r.libelle3 || ""}`
|
||||
}));
|
||||
|
||||
|
||||
@@ -71,8 +71,21 @@ export const useGridStore = create<GridState>()(
|
||||
},
|
||||
|
||||
setDraftGamme: (codein, gamme) => {
|
||||
const draftChanges = { ...get().draftChanges, [codein]: gamme };
|
||||
set({ draftChanges, summary: computeSummary(get().rows, draftChanges) });
|
||||
const { rows, draftChanges: oldDrafts } = get();
|
||||
const originalRow = rows.find(r => r.codein === codein);
|
||||
const originalGamme = originalRow?.codeGamme;
|
||||
|
||||
const draftChanges = { ...oldDrafts };
|
||||
|
||||
if (gamme === originalGamme) {
|
||||
// If the new value matches initial, remove it from drafts
|
||||
delete draftChanges[codein];
|
||||
} else {
|
||||
// Otherwise, record the change
|
||||
draftChanges[codein] = gamme;
|
||||
}
|
||||
|
||||
set({ draftChanges, summary: computeSummary(rows, draftChanges) });
|
||||
},
|
||||
|
||||
resetDrafts: () => {
|
||||
|
||||
Reference in new issue
Block a user