import React from "react"; import { useSelector } from "react-redux"; import { RootState } from "../../../redux/store"; // components/main/fall-detection-sensors/FallSensors.tsx interface FallSensorsProps { slotIndex: number; } const FallSensors: React.FC = ({ slotIndex }) => { const { kvzStatus } = useSelector((state: RootState) => state.kueDataSlice); // Nur 4 LEDs für den spezifischen Slot anzeigen const leds = Array.from({ length: 4 }, (_, ledIndex) => { const arrayIndex = slotIndex * 4 + ledIndex; const ledValue = kvzStatus?.[arrayIndex]; // LED Status: 1 = grün, 0 = rot, 2 = grau, undefined = grau if (ledValue === 1) return "green"; if (ledValue === 0) return "red"; return "gray"; // für 2 oder undefined }); return (
{/* Überschrift mit KVZ-Labels */}
KVZ1 KVZ2 KVZ3 KVZ4
{/* LEDs */}
{leds.map((ledStatus, ledIndex) => { // LED Farben: grün (1), rot (0), grau (2) let bgColor = "bg-gray-400"; // Standard grau let statusText = "Unbekannt"; if (ledStatus === "green") { bgColor = "bg-green-500"; statusText = "Ein"; } else if (ledStatus === "red") { bgColor = "bg-red-500"; statusText = "Aus"; } return (
); })}
); }; export default FallSensors;