import { useEffect, useCallback } from "react"; interface ConfirmDialogProps { isOpen: boolean; title: string; message: string; confirmText?: string; cancelText?: string; onConfirm: () => void; onCancel: () => void; variant?: "danger" | "warning"; } export function ConfirmDialog({ isOpen, title, message, confirmText = "Confirm", cancelText = "Cancel", onConfirm, onCancel, variant = "warning", }: ConfirmDialogProps) { // Handle escape key const handleEscape = useCallback( (e: KeyboardEvent) => { if (e.key === "Escape") { onCancel(); } }, [onCancel], ); useEffect(() => { if (isOpen) { document.addEventListener("keydown", handleEscape); return () => document.removeEventListener("keydown", handleEscape); } }, [isOpen, handleEscape]); if (!isOpen) return null; return (
e.stopPropagation()} role="dialog" aria-labelledby="dialog-title" aria-describedby="dialog-message" >

{title}

{message}

); }