Delete Hook
You can use methods in helpers/hooks/crudHooks.tsx file for basic crud operations. In general, you can use pre-defined components and there is no need to call these seperately. However, for custom actions we may want to add delete buttons.
For deleting operation you can use useDeletefunction. This will have isLoading, result variables and mutate function.
Here is the example usage:
const {
isLoading: deleteLoading,
result: deleteResult,
mutate: deleteArticle
} = useDelete(props.dataModel.queryNames.delete);
useEffect(() => {
if (!(deleteResult && deleteResult.data)) return;
if (deleteResult.success) {
showSuccess(t('messages:success-deleted'));
} else {
showError(t('messages:error-deleting-data'));
}
}, [deleteResult]);
deleteArticle(props.id);