'use client' import { Button } from "@/components/ui/button"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "@/components/ui/alert-dialog"; import { deletarProduto } from "../actions"; import { useState } from "react"; import { Trash2 } from "lucide-react"; import { useRouter } from "next/navigation"; interface DeleteButtonProps { produtoId: number; produtoNome: string; listaId: string; } export function DeleteButton({ produtoId, produtoNome, listaId }: DeleteButtonProps) { const [isDeleting, setIsDeleting] = useState(false); const router = useRouter(); async function handleDelete() { try { setIsDeleting(true); await deletarProduto(produtoId, listaId); router.refresh(); } finally { setIsDeleting(false); } } return ( Confirmar exclusão Tem certeza que deseja excluir o produto "{produtoNome}"? Esta ação não pode ser desfeita. Cancelar {isDeleting ? 'Excluindo...' : 'Excluir'} ); }