'use client' import { useState } from 'react' import { useRouter } from 'next/navigation' import { Trash2 } from 'lucide-react' import { Button } from '@/components/ui/button' import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '@/components/ui/dialog' interface DeleteNoteButtonProps { noteId: string noteTitle: string } export function DeleteNoteButton({ noteId, noteTitle }: DeleteNoteButtonProps) { const [open, setOpen] = useState(false) const [deleting, setDeleting] = useState(false) const router = useRouter() const handleDelete = async () => { setDeleting(true) try { const response = await fetch(`/api/notes/${noteId}`, { method: 'DELETE', }) if (response.ok) { setOpen(false) router.push('/notes') router.refresh() } } catch { setDeleting(false) } } return ( <> Eliminar nota ¿Estás seguro de que quieres eliminar "{noteTitle}"? Esta acción no se puede deshacer. ) }