mirror of
https://github.com/R0m1k3/CollectFlow.git
synced 2026-10-21 14:08:08 +02:00
fix(ui): resolve stale closure in excel export button preventing export of actual drafts
This commit is contained in:
1 parent
515ca55836
commit
09e00fbcdd
1 file changed
+9
-4
@@ -52,17 +52,22 @@ export function FloatingSummaryBar() {
|
|||||||
<div className="flex space-x-3 items-center">
|
<div className="flex space-x-3 items-center">
|
||||||
<button
|
<button
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
if (!hasDrafts) {
|
// Fetch the absolute latest state from the store at the moment of the click
|
||||||
|
const currentState = useGridStore.getState();
|
||||||
|
const currentDrafts = currentState.draftChanges;
|
||||||
|
const currentRows = currentState.rows;
|
||||||
|
|
||||||
|
if (Object.keys(currentDrafts).length === 0) {
|
||||||
alert("Aucune gamme n'a été modifiée. L'export Excel ne concerne que les modifications en cours.");
|
alert("Aucune gamme n'a été modifiée. L'export Excel ne concerne que les modifications en cours.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare payload
|
// Prepare payload using fresh state
|
||||||
const modifiedRows = useGridStore.getState().rows.filter(r => draftChanges[r.codein]);
|
const modifiedRows = currentRows.filter(r => currentDrafts[r.codein]);
|
||||||
const changes = modifiedRows.map(r => ({
|
const changes = modifiedRows.map(r => ({
|
||||||
codein: r.codein,
|
codein: r.codein,
|
||||||
gtin: r.gtin,
|
gtin: r.gtin,
|
||||||
gamme: draftChanges[r.codein] as string,
|
gamme: currentDrafts[r.codein] as string,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Extract supplier name from the first row (or a generic name)
|
// Extract supplier name from the first row (or a generic name)
|
||||||
|
|||||||
Reference in new issue
Block a user