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');