From 16d95b11f8830d0934ce56d7312b3f3248563c5c Mon Sep 17 00:00:00 2001 From: Rodolfo Ruiz Date: Mon, 1 Sep 2025 20:58:28 -0600 Subject: [PATCH] chore: refresh gridview after Add, Delete or Edit --- src/private/categories/AddOrEditCategoryForm.jsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/private/categories/AddOrEditCategoryForm.jsx b/src/private/categories/AddOrEditCategoryForm.jsx index c6938b3..5e6d9c2 100644 --- a/src/private/categories/AddOrEditCategoryForm.jsx +++ b/src/private/categories/AddOrEditCategoryForm.jsx @@ -148,7 +148,10 @@ export default function AddOrEditCategoryForm({ onAdd, initialData, onCancel }) await api.create(base); } - onAdd?.(); + // Ensure the parent refresh (loadData) happens before closing the dialog + if (onAdd) { + await onAdd(); + } } catch (e) { console.error('Submit category failed:', e); alert(e.message || 'Submit failed'); @@ -162,7 +165,9 @@ export default function AddOrEditCategoryForm({ onAdd, initialData, onCancel }) const idToUse = hex || form.id; if (!idToUse) throw new Error('Missing id to delete'); await api.changeStatus({ id: idToUse, status: 'Inactive' }); - onAdd?.(); + if (onAdd) { + await onAdd(); + } } catch (e) { console.error('Delete category failed:', e); alert(e.message || 'Delete failed');