mirror of
https://github.com/R0m1k3/CollectFlow.git
synced 2026-10-16 19:59:30 +02:00
feat: add Zustand store for grid state and a hook to save draft modifications
This commit is contained in:
1 parent
aa69637f98
commit
7cdbe8ec21
2 files changed
+17
-1
No files matched your search
@@ -10,7 +10,7 @@ import { GammeCode } from "@/types/grid";
|
||||
* Filters changes to only include those in the provided codeins list (e.g. current supplier).
|
||||
*/
|
||||
export function useSaveDrafts(magasin: string, filterCodeins?: string[]) {
|
||||
const { draftChanges, rows, resetDrafts, clearDrafts } = useGridStore();
|
||||
const { draftChanges, rows, resetDrafts, clearDrafts, applyDraftsToRows } = useGridStore();
|
||||
|
||||
// Only consider changes that are in the filter list (if provided)
|
||||
const activeDrafts = filterCodeins
|
||||
@@ -39,6 +39,9 @@ export function useSaveDrafts(magasin: string, filterCodeins?: string[]) {
|
||||
const result = await saveDraftChanges({ codeFournisseur, nomFournisseur, magasin, changes });
|
||||
|
||||
if (result.success) {
|
||||
// Apply saved values onto row.codeGamme BEFORE clearing drafts
|
||||
// so that isModified (codeGamme !== codeGammeInit) stays true
|
||||
applyDraftsToRows(activeDrafts);
|
||||
if (filterCodeins) {
|
||||
clearDrafts(Object.keys(activeDrafts));
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user