"use client"; import { useEffect, useState } from "react"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "@kandev/ui/alert-dialog"; export function DeleteWatchDialog({ open, onOpenChange, watchLabel, onConfirm, }: { open: boolean; onOpenChange: (open: boolean) => void; watchLabel: string; onConfirm: () => Promise; }) { const [deleting, setDeleting] = useState(false); const [error, setError] = useState(""); useEffect(() => { if (open) setError(""); }, [open]); return ( Delete {watchLabel}? This will delete every task created by this watch, including archived tasks, and remove its polling history. This cannot be undone. {error && (

{error}

)}
Cancel { event.preventDefault(); setDeleting(true); setError(""); try { await onConfirm(); onOpenChange(false); } catch (cause) { setError(cause instanceof Error ? cause.message : "Watch deletion failed"); } finally { setDeleting(false); } }} > {deleting ? "Deleting..." : "Delete watch"}
); }