Skip to content

The Open Source DocuSign Alternative.

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

Rohit Salujaa6ddc114d9a1
diff --git a/apps/web/src/app/(dashboard)/admin/documents/[id]/super-delete-document-dialog.tsx b/apps/web/src/app/(dashboard)/admin/documents/[id]/super-delete-document-dialog.tsx
index 346a4eccc..6d89c7e7b 100644
--- a/apps/web/src/app/(dashboard)/admin/documents/[id]/super-delete-document-dialog.tsx
+++ b/apps/web/src/app/(dashboard)/admin/documents/[id]/super-delete-document-dialog.tsx
@@ -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({