import { useEffect, type ReactNode } from "react"; import { motion, AnimatePresence } from "framer-motion"; interface ConfirmModalProps { isOpen: boolean; onClose: () => void; onConfirm: () => void; title: string; message: ReactNode; confirmText?: string; cancelText?: string; type?: "danger" | "warning" | "default" | "info"; confirmVariant?: "danger" | "primary"; loading?: boolean; } function ConfirmIcon({ type }: { type: string }) { switch (type) { case "danger": return ( ); case "info": return ( ); case "warning": return ( ); default: return ( ); } } export default function ConfirmModal({ isOpen, onClose, onConfirm, title, message, confirmText = "Potvrdit", cancelText = "Zrušit", type = "default", confirmVariant, loading, }: ConfirmModalProps) { useEffect(() => { if (!isOpen) return; function handleKeyDown(e: KeyboardEvent) { if (e.key === "Escape" && !loading) { onClose(); } } window.addEventListener("keydown", handleKeyDown); return () => window.removeEventListener("keydown", handleKeyDown); }, [isOpen, loading, onClose]); return ( {isOpen && (

{title}

{message}

)} ); }