// components/main/system/DetailModal.tsx "use client"; import React from "react"; import { Line } from "react-chartjs-2"; import { useSelector } from "react-redux"; import { RootState } from "@/redux/store"; import { Listbox } from "@headlessui/react"; type Props = { isOpen: boolean; selectedKey: string | null; onClose: () => void; zeitraum: "DIA0" | "DIA1" | "DIA2"; setZeitraum: (typ: "DIA0" | "DIA1" | "DIA2") => void; }; type ReduxDataEntry = { t: string; i: number }; export const DetailModal = ({ isOpen, selectedKey, onClose, zeitraum, setZeitraum, }: Props) => { const reduxData: ReduxDataEntry[] = useSelector((state: RootState) => { switch (selectedKey) { case "+5V": return state.systemspannung5Vplus[zeitraum] as ReduxDataEntry[]; case "+15V": return state.systemspannung15Vplus[zeitraum] as ReduxDataEntry[]; case "-15V": return state.systemspannung15Vminus[zeitraum] as ReduxDataEntry[]; case "-98V": return state.systemspannung98Vminus[zeitraum] as ReduxDataEntry[]; case "ADC Temp": return state.temperaturAdWandler[zeitraum] as ReduxDataEntry[]; case "CPU Temp": return state.temperaturProzessor[zeitraum] as ReduxDataEntry[]; default: return [] as ReduxDataEntry[]; } }); const labels = reduxData.map((e: ReduxDataEntry) => e.t); const values = reduxData.map((e: ReduxDataEntry) => e.i); const baseOptions = { responsive: true, maintainAspectRatio: false, scales: { y: { beginAtZero: false, grid: { color: "rgba(200,200,200,0.2)" }, title: { display: true, text: "Wert" }, }, x: { grid: { color: "rgba(200,200,200,0.2)" }, title: { display: true, text: "Zeit" }, }, }, plugins: { legend: { position: "bottom" as const }, title: { display: true, text: `Verlauf – ${selectedKey}` }, }, }; if (!isOpen || !selectedKey) return null; return (

Detailansicht: {selectedKey}

{ { DIA0: "Alle Messwerte", DIA1: "Stündlich", DIA2: "Täglich", }[zeitraum] } {["DIA0", "DIA1", "DIA2"].map((option) => ( `px-4 py-1 cursor-pointer ${ selected ? "bg-littwin-blue text-white" : active ? "bg-gray-200" : "" }` } > { { DIA0: "Alle Messwerte", DIA1: "Stündlich", DIA2: "Täglich", }[option] } ))}
); };