diff --git a/client/src/components/Home/MyFiles.tsx b/client/src/components/Home/MyFiles.tsx index 170c777..a2195b2 100644 --- a/client/src/components/Home/MyFiles.tsx +++ b/client/src/components/Home/MyFiles.tsx @@ -126,6 +126,8 @@ const MyFiles: React.FC = () => { // Share modal state const [shareModalOpen, setShareModalOpen] = useState(false); + const [deleteConfirmId, setDeleteConfirmId] = useState(null); + const [deleteConfirmName, setDeleteConfirmName] = useState(""); const [selectedFileForShare, setSelectedFileForShare] = useState<{ _id: string; fileName: string; @@ -817,7 +819,13 @@ const MyFiles: React.FC = () => { // ✅ Delete file const handleDelete = async (id: string) => { - if (!confirm("Are you sure you want to delete this file?")) return; + const file = files.find((f) => f.id === id); + setDeleteConfirmName(file?.name || "this file"); + setDeleteConfirmId(id); + }; + + const confirmDelete = async (id: string) => { + setDeleteConfirmId(null); try { const token = localStorage.getItem("authToken"); @@ -2564,6 +2572,57 @@ formatFileSize )} + {/* Delete Confirmation Modal */} + + {deleteConfirmId && ( + setDeleteConfirmId(null)} + > + e.stopPropagation()} + > +
+
+ +
+

+ Delete File +

+
+

+ Are you sure you want to delete{" "} + "{deleteConfirmName}"? +

+

+ This action cannot be undone. All existing share links will be permanently invalidated. +

+
+ + +
+
+
+ )} +
+ {/* Password Protection Modal */} {showPasswordModal && (