From 35685ebe1e3abf1e757094db537448f61456ce1f Mon Sep 17 00:00:00 2001 From: "[dyad]" Date: Fri, 30 Jan 2026 10:04:54 +0100 Subject: [PATCH] [dyad] Fixed crash on clip options menu - wrote 1 file(s) --- src/components/user-clips.tsx | 67 ++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/src/components/user-clips.tsx b/src/components/user-clips.tsx index 2fea53b..e266c41 100644 --- a/src/components/user-clips.tsx +++ b/src/components/user-clips.tsx @@ -6,8 +6,8 @@ import { Card, CardContent, CardFooter, CardHeader, CardTitle } from '@/componen import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; -import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger, DialogFooter, DialogClose } from '@/components/ui/dialog'; -import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger } from '@/components/ui/alert-dialog'; +import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter, DialogClose } from '@/components/ui/dialog'; +import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from '@/components/ui/alert-dialog'; import { supabase } from '@/integrations/supabase/client'; import { toast } from 'sonner'; import { Toaster } from '@/components/ui/sonner'; @@ -25,6 +25,7 @@ type UserClipsProps = { export function UserClips({ clips, onClipDeleted, onClipUpdated }: UserClipsProps) { const [clipToEdit, setClipToEdit] = useState(null); + const [clipToDelete, setClipToDelete] = useState(null); const [newTitle, setNewTitle] = useState(''); const [isSaving, setIsSaving] = useState(false); const [isDeleting, setIsDeleting] = useState(false); @@ -74,6 +75,7 @@ export function UserClips({ clips, onClipDeleted, onClipUpdated }: UserClipsProp onClipDeleted(clip.id); toast.success('Clip deleted successfully!'); + setClipToDelete(null); } catch (error) { toast.error('Failed to delete clip.'); console.error(error); @@ -112,18 +114,17 @@ export function UserClips({ clips, onClipDeleted, onClipUpdated }: UserClipsProp - handleEditClick(clip)}> - - - Edit Title - - - - - - Delete - - + handleEditClick(clip)}> + + Edit Title + + setClipToDelete(clip)} + > + + Delete + @@ -154,25 +155,6 @@ export function UserClips({ clips, onClipDeleted, onClipUpdated }: UserClipsProp {hasCopied === clip.short_id ? 'Copied!' : 'Copy Link'} - - {/* Delete Confirmation Dialog */} - - - - Are you sure? - - This action cannot be undone. This will permanently delete your clip and its thumbnail from our servers. - - - - Cancel - handleDeleteClip(clip)} disabled={isDeleting} className="bg-destructive hover:bg-destructive/90"> - {isDeleting && } - Delete - - - - ))} @@ -209,6 +191,25 @@ export function UserClips({ clips, onClipDeleted, onClipUpdated }: UserClipsProp + + {/* Delete Confirmation Dialog */} + !isOpen && setClipToDelete(null)}> + + + Are you sure? + + This action cannot be undone. This will permanently delete your clip and its thumbnail from our servers. + + + + Cancel + clipToDelete && handleDeleteClip(clipToDelete)} disabled={isDeleting} className="bg-destructive hover:bg-destructive/90"> + {isDeleting && } + Delete + + + + ); } \ No newline at end of file