/** * System Alerts Widget * Displays important system notifications and alerts */ import React from "react"; import { __ } from "../../lib/i18n"; import { Card, CardContent, CardHeader, CardTitle } from "../ui/card"; import { Badge } from "../ui/badge"; import { AlertCircle, Info, AlertTriangle, CheckCircle } from "lucide-react"; interface Alert { id: number; type: "info" | "warning" | "error" | "success"; message: string; timestamp: string; action?: { label: string; onClick: () => void; }; } interface SystemAlertsProps { alerts: Alert[]; loading?: boolean; } /** * System Alerts Widget */ export const SystemAlerts: React.FC = ({ alerts, loading = false, }) => { const getIcon = (type: Alert["type"]) => { switch (type) { case "error": return ; case "warning": return ; case "success": return ; default: return ; } }; if (loading) { return ( {__("System Alerts", "yatra")}
{__("Loading...", "yatra")}
); } const criticalAlerts = alerts?.filter((a) => a.type === "error" || a.type === "warning") || []; const hasAlerts = alerts && alerts.length > 0; return (
{__("System Alerts", "yatra")} {criticalAlerts.length > 0 && ( {criticalAlerts.length} {__("critical", "yatra")} )}
{hasAlerts ? (
{alerts.slice(0, 5).map((alert) => (
{getIcon(alert.type)}

{alert.message}

{new Date(alert.timestamp).toLocaleString()}

{alert.action && ( )}
))}
) : (
{__("All systems operational", "yatra")}
)}
); }; export default SystemAlerts;