"use client"; import { useEffect, useRef, useState } from "react"; import { X, AlertTriangle } from "lucide-react"; interface ConfirmModalProps { isOpen: boolean; onClose: () => void; onConfirm: () => void; title?: string; message: string; confirmLabel?: string; cancelLabel?: string; variant?: "danger" | "default"; } export function ConfirmModal({ isOpen, onClose, onConfirm, title = "Confirmation", message, confirmLabel = "OK", cancelLabel = "Annuler", variant = "default", }: ConfirmModalProps) { const [isVisible, setIsVisible] = useState(false); const confirmBtnRef = useRef(null); useEffect(() => { if (isOpen) { setIsVisible(true); setTimeout(() => confirmBtnRef.current?.focus(), 50); } else { setIsVisible(false); } }, [isOpen]); const handleClose = () => { setIsVisible(false); setTimeout(onClose, 250); }; const handleConfirm = () => { setIsVisible(false); setTimeout(onConfirm, 250); }; const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === "Escape") handleClose(); if (e.key === "Enter") handleConfirm(); }; if (!isOpen && !isVisible) return null; const isDanger = variant === "danger"; return (
{/* Backdrop */}
{/* Panel */}
{/* Accent bar */}
{/* Close button */}
{/* Icon + Title */}

{title}

{/* Message */}

{message}

{/* Actions */}
); }