chore: refresh gridview after Add, Delete or Edit
This commit is contained in:
@@ -148,7 +148,10 @@ export default function AddOrEditCategoryForm({ onAdd, initialData, onCancel })
|
|||||||
await api.create(base);
|
await api.create(base);
|
||||||
}
|
}
|
||||||
|
|
||||||
onAdd?.();
|
// Ensure the parent refresh (loadData) happens before closing the dialog
|
||||||
|
if (onAdd) {
|
||||||
|
await onAdd();
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Submit category failed:', e);
|
console.error('Submit category failed:', e);
|
||||||
alert(e.message || 'Submit failed');
|
alert(e.message || 'Submit failed');
|
||||||
@@ -162,7 +165,9 @@ export default function AddOrEditCategoryForm({ onAdd, initialData, onCancel })
|
|||||||
const idToUse = hex || form.id;
|
const idToUse = hex || form.id;
|
||||||
if (!idToUse) throw new Error('Missing id to delete');
|
if (!idToUse) throw new Error('Missing id to delete');
|
||||||
await api.changeStatus({ id: idToUse, status: 'Inactive' });
|
await api.changeStatus({ id: idToUse, status: 'Inactive' });
|
||||||
onAdd?.();
|
if (onAdd) {
|
||||||
|
await onAdd();
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Delete category failed:', e);
|
console.error('Delete category failed:', e);
|
||||||
alert(e.message || 'Delete failed');
|
alert(e.message || 'Delete failed');
|
||||||
|
|||||||
Reference in New Issue
Block a user