import React from "react"; import { Button } from "@/components/button.tsx"; import { Badge } from "@/components/badge.tsx"; import { X, ExternalLink, AlertTriangle, Info, CheckCircle, AlertCircle, } from "lucide-react"; import { useTranslation } from "react-i18next"; import type { TermixAlert } from "@/types"; interface AlertCardProps { alert: TermixAlert; onDismiss: (alertId: string) => void; onClose: () => void; } const getAlertIcon = (type?: string) => { switch (type) { case "warning": return ; case "error": return ; case "success": return ; case "info": default: return ; } }; const getAccentBarClass = (priority?: string, type?: string): string => { if (priority === "critical" || type === "error") return "bg-destructive"; if (priority === "high" || type === "warning") return "bg-accent-brand"; if (priority === "medium" || type === "success") return "bg-green-400"; return "bg-border"; }; const getPriorityBadgeVariant = ( priority?: string, ): "destructive" | "secondary" | "outline" => { switch (priority) { case "critical": case "high": return "destructive"; case "medium": return "secondary"; case "low": default: return "outline"; } }; const getTypeBadgeVariant = ( type?: string, ): "destructive" | "secondary" | "outline" => { switch (type) { case "error": return "destructive"; case "warning": return "secondary"; case "success": case "info": default: return "outline"; } }; export function AlertCard({ alert, onDismiss, onClose, }: AlertCardProps): React.ReactElement | null { const { t } = useTranslation(); if (!alert) { return null; } const handleDismiss = () => { onDismiss(alert.id); onClose(); }; return (
{getAlertIcon(alert.type)} {alert.title}
{(alert.priority || alert.type) && (
{alert.priority && ( {alert.priority.toUpperCase()} )} {alert.type && ( {alert.type} )}
)}

{alert.message}

{alert.actionUrl && alert.actionText && ( )}
); }