"use client" import { useEffect, useRef } from "react" import { AlertTriangle, X } from "lucide-react" import { cn } from "@/lib/utils" interface ConfirmModalProps { open: boolean title?: string description?: string confirmLabel?: string cancelLabel?: string variant?: "danger" | "warning" loading?: boolean onConfirm: () => void onCancel: () => void } export function ConfirmModal({ open, title = "Are you sure?", description = "This action cannot be undone.", confirmLabel = "Delete", cancelLabel = "Cancel", variant = "danger", loading = false, onConfirm, onCancel, }: ConfirmModalProps) { const confirmRef = useRef(null) useEffect(() => { if (open) setTimeout(() => confirmRef.current?.focus(), 50) }, [open]) useEffect(() => { function onKey(e: KeyboardEvent) { if (e.key === "Escape" && open) onCancel() } document.addEventListener("keydown", onKey) return () => document.removeEventListener("keydown", onKey) }, [open, onCancel]) if (!open) return null const isDanger = variant === "danger" return (
{/* Backdrop */}
{/* Modal */}
{/* Close */}
{/* Icon */}

{title}

{description}

{/* Actions */}
) }