"use client"; import { useEffect, useState } from "react"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "@kandev/ui/alert-dialog"; import { useTranslation } from "react-i18next"; export function DeleteWatchDialog({ open, onOpenChange, watchLabel, onConfirm, }: { open: boolean; onOpenChange: (open: boolean) => void; watchLabel: string; onConfirm: () => Promise; }) { const { t } = useTranslation(); const [deleting, setDeleting] = useState(false); const [error, setError] = useState(""); useEffect(() => { if (open) setError(""); }, [open]); return ( {/* One message, not "Delete" + label: the label's position in the sentence is the translator's to choose. */} {t("gitlab:deleteWatchTitle", { label: watchLabel })} {t("gitlab:thisWillDeleteEveryTaskCreated")} {error && (

{error}

)}
{t("common:cancel")} { event.preventDefault(); setDeleting(true); setError(""); try { await onConfirm(); onOpenChange(false); } catch (cause) { setError(cause instanceof Error ? cause.message : t("gitlab:watchDeletionFailed")); } finally { setDeleting(false); } }} > {deleting ? t("gitlab:deleting") : t("gitlab:deleteWatch")}
); }