'use client' import { cn, formatRelativeTime } from '@/lib/utils' export type AlertSeverity = 'CRITICAL' | 'WARNING' | 'INFO' export type AlertStatus = 'ACTIVA' | 'RECONOCIDA' | 'RESUELTA' export interface AlertCardData { id: string title: string device: string description: string severity: AlertSeverity timestamp: Date | string status: AlertStatus } interface AlertCardProps { alert: AlertCardData onAcknowledge?: (id: string) => void onResolve?: (id: string) => void } const severityStyles = { CRITICAL: { bar: 'bg-red-500', badge: 'bg-red-500/20 text-red-400 border-red-500/40', label: 'CRÍTICO', }, WARNING: { bar: 'bg-amber-500', badge: 'bg-amber-500/20 text-amber-400 border-amber-500/40', label: 'ADVERTENCIA', }, INFO: { bar: 'bg-blue-500', badge: 'bg-blue-500/20 text-blue-400 border-blue-500/40', label: 'INFO', }, } export default function AlertCard({ alert, onAcknowledge, onResolve }: AlertCardProps) { const style = severityStyles[alert.severity] const ts = typeof alert.timestamp === 'string' ? new Date(alert.timestamp) : alert.timestamp return (

{alert.title}

{alert.device}

{alert.description}

{formatRelativeTime(ts)}

{style.label} {alert.status === 'ACTIVA' && (
)} {alert.status !== 'ACTIVA' && ( {alert.status === 'RECONOCIDA' ? 'Leída' : 'Resuelta'} )}
) }