From b43f794956eac1522183ca88c56d08c759afe19d 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 14:00:13 +0000 Subject: [PATCH] Refactor: Simplify photo management modal --- .../upload/PhotoManagementDialog.tsx | 101 ++---------------- 1 file changed, 11 insertions(+), 90 deletions(-) diff --git a/src/components/upload/PhotoManagementDialog.tsx b/src/components/upload/PhotoManagementDialog.tsx index 16f78607..61eb9637 100644 --- a/src/components/upload/PhotoManagementDialog.tsx +++ b/src/components/upload/PhotoManagementDialog.tsx @@ -13,7 +13,7 @@ import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Textarea } from '@/components/ui/textarea'; import { useToast } from '@/hooks/use-toast'; -import { ArrowUp, ArrowDown, Trash2, Star, StarOff, Pencil } from 'lucide-react'; +import { ArrowUp, ArrowDown, Trash2, Pencil } from 'lucide-react'; import { Card, CardContent } from '@/components/ui/card'; interface Photo { @@ -123,44 +123,6 @@ export function PhotoManagementDialog({ } }; - const toggleFeatured = async (photoId: string) => { - try { - const photo = photos.find((p) => p.id === photoId); - if (!photo) return; - - // If setting as featured, unset all other photos - if (!photo.is_featured) { - await supabase - .from('photos') - .update({ is_featured: false }) - .eq('entity_type', entityType) - .eq('entity_id', entityId); - } - - const { error } = await supabase - .from('photos') - .update({ is_featured: !photo.is_featured }) - .eq('id', photoId); - - if (error) throw error; - - await fetchPhotos(); - toast({ - title: 'Success', - description: photo.is_featured - ? 'Photo removed from featured' - : 'Photo set as featured', - }); - onUpdate?.(); - } catch (error) { - console.error('Error updating featured status:', error); - toast({ - title: 'Error', - description: 'Failed to update featured status', - variant: 'destructive', - }); - } - }; const deletePhoto = async (photoId: string) => { if (!confirm('Are you sure you want to delete this photo?')) return; @@ -193,7 +155,6 @@ export function PhotoManagementDialog({ const { error } = await supabase .from('photos') .update({ - title: editingPhoto.title, caption: editingPhoto.caption, }) .eq('id', editingPhoto.id); @@ -223,30 +184,18 @@ export function PhotoManagementDialog({ Edit Photo - Update photo details + Update photo caption
{editingPhoto.title
-
- - - setEditingPhoto({ ...editingPhoto, title: e.target.value }) - } - placeholder="Photo title" - /> -
-