import Button from "./Button";
import Dialog from "./Dialog";
import { usePlatformLanguage } from "../i18n/LanguageContext";

export type ConfirmDialogTone = "default" | "danger";

export type ConfirmDialogProps = {
  open: boolean;
  title: string;
  message: string;
  confirmLabel?: string;
  cancelLabel?: string;
  tone?: ConfirmDialogTone;
  busy?: boolean;
  onConfirm: () => void;
  onCancel: () => void;
};

export default function ConfirmDialog({
  open,
  title,
  message,
  confirmLabel = "i18n:govoplan-core.confirm.04a21221",
  cancelLabel = "i18n:govoplan-core.cancel.77dfd213",
  tone = "default",
  busy = false,
  onConfirm,
  onCancel
}: ConfirmDialogProps) {
  const { translateText } = usePlatformLanguage();
  return (
    <Dialog
      open={open}
      title={title}
      role="alertdialog"
      className="confirm-dialog"
      footerClassName="button-row compact-actions"
      closeOnBackdrop={!busy}
      closeDisabled={busy}
      showCloseButton
      onClose={onCancel}
      footer={
      <>
          <Button onClick={onCancel} disabled={busy}>{translateText(cancelLabel)}</Button>
          <Button variant={tone === "danger" ? "danger" : "primary"} onClick={onConfirm} disabled={busy}>{busy ? translateText("i18n:govoplan-core.working.13b7bfca") : translateText(confirmLabel)}</Button>
        </>
      }>
      
      <p>{translateText(message)}</p>
    </Dialog>);

}
