"use client"; // IsoChartView.tsx import React, { useEffect, useRef } from "react"; import { Listbox } from "@headlessui/react"; import ReactModal from "react-modal"; import IsoMeasurementChart from "./IsoMeasurementChart"; import IsoChartActionBar from "./IsoChartActionBar"; import Report from "./Report"; import { useSelector, useDispatch } from "react-redux"; import { AppDispatch } from "@/redux/store"; import { RootState } from "@/redux/store"; import { setChartOpen, setFullScreen, setSlotNumber, setChartTitle, } from "@/redux/slices/kabelueberwachungChartSlice"; import { resetBrushRange } from "@/redux/slices/brushSlice"; import { setVonDatum, setBisDatum, setSelectedMode, setSelectedSlotType, } from "@/redux/slices/kabelueberwachungChartSlice"; import { resetDateRange } from "@/redux/slices/dateRangePickerSlice"; interface IsoChartViewProps { isOpen: boolean; onClose: () => void; slotIndex: number; } const IsoChartView: React.FC = ({ isOpen, onClose, slotIndex, }) => { const dispatch = useDispatch(); // removed unused loadData const { isFullScreen, chartTitle } = useSelector( (state: RootState) => state.kabelueberwachungChartSlice ); // **Modal schließen + Redux-Status zurücksetzen** const handleClose = () => { const today = new Date(); const thirtyDaysAgo = new Date(); thirtyDaysAgo.setDate(today.getDate() - 30); const toISO = (date: Date) => date.toLocaleDateString("sv-SE"); // Reset Datum dispatch(setVonDatum(toISO(thirtyDaysAgo))); dispatch(setBisDatum(toISO(today))); // Reset DateRangePicker dispatch(resetDateRange()); // Reset Dropdowns dispatch(setSelectedMode("DIA0")); // Reset to Alle Messwerte dispatch(setSelectedSlotType("isolationswiderstand")); dispatch(setChartTitle("Messkurve")); // Reset zu Messkurve // Sonstiges Reset dispatch(setChartOpen(false)); dispatch(setFullScreen(false)); dispatch(resetBrushRange()); onClose(); }; // **Vollbildmodus umschalten** const toggleFullScreen = () => { dispatch(setFullScreen(!isFullScreen)); }; // Modal öffnen - ISO spezifische Einstellungen type ActionBarRefType = { handleFetchData: () => void }; const actionBarRef = useRef(null); useEffect(() => { if (isOpen) { const today = new Date(); const thirtyDaysAgo = new Date(); thirtyDaysAgo.setDate(today.getDate() - 30); const toISO = (date: Date) => date.toLocaleDateString("sv-SE"); // Set slot number first dispatch(setSlotNumber(slotIndex)); // Set dates dispatch(setVonDatum(toISO(thirtyDaysAgo))); dispatch(setBisDatum(toISO(today))); // Set ISO specific settings dispatch(setSelectedSlotType("isolationswiderstand")); dispatch(setSelectedMode("DIA0")); // Set to Alle Messwerte on open // Set default to Messkurve dispatch(setChartTitle("Messkurve")); // Automatisch Daten laden wie Button-Klick const timer = setTimeout(() => { actionBarRef.current?.handleFetchData(); }, 120); // Cleanup timer return () => clearTimeout(timer); } // eslint-disable-next-line react-hooks/exhaustive-deps }, [isOpen, slotIndex, dispatch]); return ( {/* Action-Buttons */}
{/* Fullscreen-Button */} {/* Schließen-Button */}
{/* Chart-Container */}

Isolationswiderstand

dispatch(setChartTitle(value)) } >
{chartTitle === "Meldungen" ? "Meldungen" : "Messkurve"} {(["Messkurve", "Meldungen"] as const).map((option) => ( `px-4 py-1 cursor-pointer ${ selected ? "bg-littwin-blue text-white" : active ? "bg-gray-200" : "" }` } > {option === "Meldungen" ? "Meldungen" : "Messkurve"} ))}
{chartTitle === "Messkurve" ? ( ) : ( )}
); }; export default IsoChartView;