chore: refresh gridview after Add, Delete or Edit

This commit is contained in:
Rodolfo Ruiz
2025-09-01 20:58:28 -06:00
parent 304d5a6e59
commit 16d95b11f8

View File

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