mirror of
https://github.com/R0m1k3/CollectFlow.git
synced 2026-10-11 17:26:32 +02:00
fix: correct snapshot save to detect all gamme changes (drafts + validated)
handleSnapshot was only looking at active draftChanges to build the snapshot. After validation (Valider), drafts are cleared but changes are applied to row.codeGamme via applyDraftsToRows. This caused handleSnapshot (Camera/Export) to save an empty snapshot that overwrote the real one, losing all gamme changes on page reload. Now handleSnapshot compares (draftChanges[codein] ?? row.codeGamme) vs row.codeGammeInit to detect ALL changes, whether drafted or already validated. Uses codeGammeInit as "before" reference (API value, never modified). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
01d2dc8b34
commit
414bf6133d
1 file changed
+6
-2
@@ -60,13 +60,17 @@ export function FloatingSummaryBar() {
|
||||
if (rows.length === 0) return;
|
||||
setIsSavingSnapshot(true);
|
||||
try {
|
||||
const modifiedRows = rows.filter(r => draftChanges[r.codein]);
|
||||
// Détecter TOUS les changements : drafts actifs + changements déjà validés (codeGamme mis à jour)
|
||||
const modifiedRows = rows.filter(r => {
|
||||
const effectiveGamme = draftChanges[r.codein] ?? r.codeGamme;
|
||||
return effectiveGamme !== r.codeGammeInit;
|
||||
});
|
||||
const changes = Object.fromEntries(
|
||||
modifiedRows.map(r => [
|
||||
r.codein,
|
||||
{
|
||||
before: r.codeGammeInit,
|
||||
after: draftChanges[r.codein] as string
|
||||
after: (draftChanges[r.codein] ?? r.codeGamme) as string
|
||||
}
|
||||
])
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user