import { type ReactNode } from "react"; import { useTranslation } from "react-i18next"; import * as Dialog from "@/components/dialog/Dialog"; import { Button } from "@/components/buttons/Button"; import { DialogHeading } from "@/components/dialog/DialogHeading"; import { DialogDescription } from "@/components/dialog/DialogDescription"; import { DialogActions } from "@/components/dialog/DialogActions"; type ConfirmModalProps = { open: boolean; title: ReactNode; description: ReactNode; confirmLabel: string; cancelLabel?: string; danger?: boolean; busy?: boolean; cancellable?: boolean; onConfirm: () => void; onCancel: () => void; }; export const ConfirmModal = ({ open, title, description, confirmLabel, cancelLabel, danger = false, busy = false, cancellable, onConfirm, onCancel, }: ConfirmModalProps) => { const { t } = useTranslation(); const resolvedCancel = cancelLabel ?? t("common.cancel"); const canCancel = cancellable ?? !busy; const srTitle = typeof title === "string" ? title : undefined; const srDescription = typeof description === "string" ? description : undefined; return ( { if (!next && canCancel) onCancel(); }} > e.preventDefault()} >
{title} {description}
); };