fix: a condition is added for the reason in the handler

This commit is contained in:
Rohit Saluja
2024-03-26 18:53:03 +05:30
parent abb49c349c
commit a6ddc114d9

View File

@ -34,13 +34,15 @@ export const SuperDeleteDocumentDialog = ({ document }: SuperDeleteDocumentDialo
const handleDeleteDocument = async () => {
try {
await deleteDocument({ id: document.id, userId: document.userId, reason });
toast({
title: 'Document deleted',
description: 'The Document has been deleted successfully.',
duration: 5000,
});
router.push('/admin/documents');
if (reason) {
await deleteDocument({ id: document.id, userId: document.userId, reason });
toast({
title: 'Document deleted',
description: 'The Document has been deleted successfully.',
duration: 5000,
});
router.push('/admin/documents');
}
} catch (err) {
if (err instanceof TRPCClientError && err.data?.code === 'BAD_REQUEST') {
toast({