import {
  AlertDialog,
  AlertDialogAction,
  AlertDialogCancel,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogFooter,
  AlertDialogHeader,
  AlertDialogTitle,
} from "@/ui";
import { SyntheticEvent } from "react";
import { Link } from "react-router-dom";

interface CustomDialogProps {
  isOpen: boolean;
  onCancel: (event: SyntheticEvent) => void;
  onConfirm: (event: SyntheticEvent) => void;
  title: React.ReactNode;
  description: React.ReactNode;
  cancelLabel: React.ReactNode;
  confirmLabel: React.ReactNode;
}

export const CustomDialog = ({
  isOpen,
  onCancel,
  onConfirm,
  title,
  description,
  cancelLabel,
  confirmLabel,
}: CustomDialogProps) => {
  return (
    <AlertDialog open={isOpen}>
      <AlertDialogContent>
        <AlertDialogHeader>
          <AlertDialogTitle>{title}</AlertDialogTitle>
          <AlertDialogDescription>{description}</AlertDialogDescription>
        </AlertDialogHeader>
        <AlertDialogFooter>
          <AlertDialogCancel>
            <Link to='#' onClick={onCancel}>
              {cancelLabel}
            </Link>
          </AlertDialogCancel>
          <AlertDialogAction>
            <Link to='#' onClick={onConfirm}>
              {confirmLabel}
            </Link>
          </AlertDialogAction>
        </AlertDialogFooter>
      </AlertDialogContent>
    </AlertDialog>
  );
};
