"use client"; import { useState } from "react"; import { Button } from "@/components/ui/button"; import { Trash2, Loader2 } from "lucide-react"; import { deleteForm } from "@/app/actions/form"; import { toast } from "sonner"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; interface DeleteFormButtonProps { formId: string; } export default function DeleteFormButton({ formId }: DeleteFormButtonProps) { const [open, setOpen] = useState(false); const [deleting, setDeleting] = useState(false); const handleDelete = async () => { setDeleting(true); try { await deleteForm(formId); toast.success("Form deleted successfully!"); setOpen(false); } catch (err: any) { toast.error(err.message || "Failed to delete form."); } finally { setDeleting(false); } }; return ( Are you absolutely sure? This action cannot be undone. This will permanently delete the form, all of its questions, and all submissions/answers. ); }