diff --git a/backend/routes/apiRoutes.js b/backend/routes/apiRoutes.js index aab4a8a..c5d80f4 100644 --- a/backend/routes/apiRoutes.js +++ b/backend/routes/apiRoutes.js @@ -638,7 +638,7 @@ router.delete('/assets/:id', protect, async (req, res) => { if (!asset) return res.status(404).json({ message: 'Ảnh không tồn tại' }); // Kiểm tra quyền: Người upload hoặc Admin (Chủ sở hữu) - const isOwner = asset.uploadedBy.toString() === req.user._id.toString(); + const isOwner = asset.uploadedBy && asset.uploadedBy.toString() === req.user._id.toString(); const isAdmin = req.user.role === 'Chủ sở hữu' || req.user.role === 'admin'; if (!isOwner && !isAdmin) { @@ -659,7 +659,7 @@ router.delete('/assets/:id', protect, async (req, res) => { } // 2. Xóa file vật lý trên disk - if (fs.existsSync(asset.filePath)) { + if (asset.filePath && fs.existsSync(asset.filePath)) { fs.unlinkSync(asset.filePath); } diff --git a/frontend/css/style.css b/frontend/css/style.css index cb70bb3..c1f86f5 100644 --- a/frontend/css/style.css +++ b/frontend/css/style.css @@ -594,7 +594,9 @@ html, body { box-shadow: 0 10px 40px rgba(0,0,0,0.6) !important; } -#logout-confirm-modal { +#logout-confirm-modal, +#delete-asset-confirm-modal, +#success-modal { z-index: 5500; /* Cao hơn Dashboard (4500) và Close Button (5000) */ } diff --git a/frontend/index.html b/frontend/index.html index 820873f..b17f809 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -132,7 +132,7 @@ + + + + + +