/** * Confirmation Dialog Component * Displays a modal confirmation dialog for destructive actions */ import React from "react"; import { AlertTriangle, Loader2 } from "lucide-react"; import { __ } from "../../lib/i18n"; import { Button } from "./button"; import { Modal } from "./modal"; interface ConfirmationDialogProps { isOpen: boolean; onClose: () => void; onConfirm: () => void; title?: string; message?: string; description?: string; confirmText?: string; cancelText?: string; variant?: "danger" | "warning" | "info"; isLoading?: boolean; icon?: React.ReactNode; secondaryAction?: { label: string; onClick: () => void; variant?: "default" | "outline" | "ghost" | "destructive"; }; } export const ConfirmationDialog: React.FC = ({ isOpen, onClose, onConfirm, title, message, description, confirmText, cancelText, variant = "danger", isLoading = false, icon, secondaryAction, }) => { // Use description if provided, otherwise fall back to message const displayMessage = description || message || ""; const getVariantStyles = () => { switch (variant) { case "danger": return "text-red-600 dark:text-red-400"; case "warning": return "text-yellow-600 dark:text-yellow-400"; case "info": return "text-blue-600 dark:text-blue-400"; default: return "text-gray-600 dark:text-gray-400"; } }; const getButtonVariant = () => { switch (variant) { case "danger": return "destructive"; case "warning": return "default"; case "info": return "default"; default: return "default"; } }; return (
{icon || }
{title || __("Confirm Action", "yatra")}
} hideHeader={false} hideFooter={false} size="sm" panelClassName="yatra-confirmation-ui yatra-model-ui" bodyClassName="px-6 py-5" footer={
{secondaryAction && ( )}
} >

{displayMessage}

); };