import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { Button } from "@/components/ui/button" import { Badge } from "@/components/ui/badge" import { AlertTriangle, VolumeX, CheckCircle, Bell } from "lucide-react" import { useBedPressureStore } from "@/stores/bedPressureStore" import { useEffect, useState } from "react" export function AlarmDashboard() { const { activeAlarms, isConnected, acknowledgeAlarm, silenceAllAlarms } = useBedPressureStore() const [unsilencedAlarms, setUnsilencedAlarms] = useState(0) // Update alarm counts useEffect(() => { const unsilenced = activeAlarms.filter(alarm => !alarm.silenced).length setUnsilencedAlarms(unsilenced) }, [activeAlarms]) const getSystemStatus = () => { const alarmCount = activeAlarms.filter(a => a.type === 'alarm' && !a.silenced).length const warningCount = activeAlarms.filter(a => a.type === 'warning' && !a.silenced).length if (alarmCount > 0) return { status: 'ALARM', color: 'text-red-600 bg-red-50 border-red-200', count: alarmCount } if (warningCount > 0) return { status: 'WARNING', color: 'text-yellow-600 bg-yellow-50 border-yellow-200', count: warningCount } return { status: 'NORMAL', color: 'text-green-600 bg-green-50 border-green-200', count: 0 } } const systemStatus = getSystemStatus() return (
{isConnected ? 'Hardware Connected' : 'Hardware Offline'} • {activeAlarms.length} Active Alarms • {unsilencedAlarms} Unsilenced
{activeAlarms.filter(a => a.type === 'alarm' && !a.silenced).length}
{activeAlarms.filter(a => a.type === 'warning' && !a.silenced).length}
{activeAlarms.filter(a => a.silenced).length}
{activeAlarms.filter(a => a.acknowledged).length}
No active alarms
{alarm.sensorLabel}
{alarm.type.toUpperCase()} • Value: {alarm.value.toFixed(0)} • {alarm.time}