Overview
TheDeleteModal component displays a confirmation dialog before permanently deleting a document. It includes a warning message and requires explicit user confirmation to prevent accidental deletions.
Props
The unique identifier of the document/room to delete.
Features
- Confirmation dialog: Prevents accidental deletions with explicit confirmation
- Loading state: Shows “Deleting…” text during deletion
- Error handling: Catches and logs deletion errors
- Auto-redirect: Automatically redirects to home after successful deletion (handled by
deleteDocumentaction) - Icon trigger: Delete icon button that opens the modal
- Styled dialog: Uses custom
shad-dialogstyling
Usage Example
In Document List
Fromapp/(root)/page.tsx:
In Editor Toolbar
Dialog Structure
The modal consists of:- Trigger: Trash icon button
- Header: Delete icon and title
- Description: Warning message about permanent deletion
- Footer: Cancel and Delete buttons
Implementation
Permissions
The component can be rendered for any user, but the server action will reject deletion attempts from users without proper permissions.Visual Elements
Trigger Button
Dialog Content
- Icon: Delete modal icon (48x48px)
- Title: “Delete document”
- Description: Warning about permanent deletion
- Buttons:
- Cancel (dark background)
- Delete (red gradient, destructive variant)
State Management
The component manages two local states:open: Controls dialog visibilityloading: Tracks deletion in progress
Type Definition
Fromtypes/index.d.ts:
Related Components
- AddDocumentBtn - Create new documents
- CollaborativeRoom - Document editing interface
- ShareModal - Share documents
Related Functions
- deleteDocument - Server action called by this component
Source Reference
components/DeleteModal.tsx