import { View } from 'react-native'; import { ThemedText } from '@/components/ThemedText'; import { colors } from '@/theme/colors'; import { spacing } from '@/theme/spacing'; import { AlertPriority, type Alert } from '@/types/mat'; type SeverityLevel = 'URGENT' | 'HIGH' | 'NORMAL'; type AlertCardProps = { alert: Alert; }; type SeverityMeta = { label: SeverityLevel; icon: string; color: string; }; const resolveSeverity = (alert: Alert): SeverityMeta => { if (alert.priority === AlertPriority.Critical) { return { label: 'URGENT', icon: '‼', color: colors.danger, }; } if (alert.priority === AlertPriority.High) { return { label: 'HIGH', icon: '⚠', color: colors.warn, }; } return { label: 'NORMAL', icon: '•', color: colors.accent, }; }; const formatTime = (value?: string): string => { if (!value) { return 'Unknown'; } try { return new Date(value).toLocaleTimeString(); } catch { return 'Unknown'; } }; export const AlertCard = ({ alert }: AlertCardProps) => { const severity = resolveSeverity(alert); return ( {severity.icon} {severity.label} {formatTime(alert.created_at)} {alert.message} ); };