From 93750bdb042e69e55ee9bd279318848cff65fc62 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Thu, 2 Oct 2025 19:03:04 +0000 Subject: [PATCH] Refactor: Use Radix UI Dialog --- .../upload/PhotoManagementDialog.tsx | 79 ++++++++++++++++--- 1 file changed, 69 insertions(+), 10 deletions(-) diff --git a/src/components/upload/PhotoManagementDialog.tsx b/src/components/upload/PhotoManagementDialog.tsx index ef96cc00..09871c18 100644 --- a/src/components/upload/PhotoManagementDialog.tsx +++ b/src/components/upload/PhotoManagementDialog.tsx @@ -9,6 +9,16 @@ import { DialogHeader, DialogTitle, } from '@/components/ui/dialog'; +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, +} from '@/components/ui/alert-dialog'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Textarea } from '@/components/ui/textarea'; @@ -43,6 +53,9 @@ export function PhotoManagementDialog({ const [photos, setPhotos] = useState([]); const [loading, setLoading] = useState(false); const [editingPhoto, setEditingPhoto] = useState(null); + const [deleteDialogOpen, setDeleteDialogOpen] = useState(false); + const [photoToDelete, setPhotoToDelete] = useState(null); + const [deleteReason, setDeleteReason] = useState(''); const { toast } = useToast(); useEffect(() => { @@ -77,9 +90,14 @@ export function PhotoManagementDialog({ - const requestPhotoDelete = async (photoId: string, photo: Photo) => { - const reason = prompt('Please provide a reason for deleting this photo:'); - if (!reason) return; + const handleDeleteClick = (photo: Photo) => { + setPhotoToDelete(photo); + setDeleteReason(''); + setDeleteDialogOpen(true); + }; + + const requestPhotoDelete = async () => { + if (!photoToDelete || !deleteReason.trim()) return; try { // Get current user @@ -93,10 +111,10 @@ export function PhotoManagementDialog({ user_id: user.id, submission_type: 'photo_delete', content: { - photo_id: photoId, + photo_id: photoToDelete.id, entity_type: entityType, entity_id: entityId, - reason: reason + reason: deleteReason } }]) .select() @@ -111,12 +129,12 @@ export function PhotoManagementDialog({ submission_id: submission.id, item_type: 'photo_delete', item_data: { - photo_id: photoId, + photo_id: photoToDelete.id, entity_type: entityType, entity_id: entityId, - cloudflare_image_url: photo.cloudflare_image_url, - caption: photo.caption, - reason: reason + cloudflare_image_url: photoToDelete.cloudflare_image_url, + caption: photoToDelete.caption, + reason: deleteReason }, status: 'pending' }); @@ -127,6 +145,9 @@ export function PhotoManagementDialog({ title: 'Delete request submitted', description: 'Your photo deletion request has been submitted for moderation', }); + setDeleteDialogOpen(false); + setPhotoToDelete(null); + setDeleteReason(''); onOpenChange(false); } catch (error) { console.error('Error requesting photo deletion:', error); @@ -301,7 +322,7 @@ export function PhotoManagementDialog({ + + + + + Request Photo Deletion + + Please provide a reason for deleting this photo. This request will be reviewed by moderators. + + + +
+ +