fix: KÜ slotnummer in der Messkurven Modal
This commit is contained in:
@@ -4,6 +4,7 @@ import React, { useEffect } from "react";
|
||||
import ReactModal from "react-modal";
|
||||
import LoopChartActionBar from "./LoopMeasurementChart/LoopChartActionBar";
|
||||
import LoopMeasurementChart from "./LoopMeasurementChart/LoopMeasurementChart";
|
||||
import IsoMeasurementChart from "./IsoMeasurementChart/IsoMeasurementChart";
|
||||
import TDRChart from "./TDRChart/TDRChart";
|
||||
import { useSelector, useDispatch } from "react-redux";
|
||||
import { AppDispatch } from "@/redux/store";
|
||||
@@ -86,9 +87,9 @@ const ChartSwitcher: React.FC<ChartSwitcherProps> = ({ isOpen, onClose }) => {
|
||||
(state: RootState) => state.kabelueberwachungChartSlice.slotNumber
|
||||
);
|
||||
|
||||
// immer beim Öffnen das Modal die letzten 30 Tage anzeigen
|
||||
// immer beim Öffnen das Modal die letzten 30 Tage anzeigen und SlotType setzen
|
||||
useEffect(() => {
|
||||
if (isOpen && activeMode === "Schleife" && slotNumber !== null) {
|
||||
if (isOpen) {
|
||||
const today = new Date();
|
||||
const thirtyDaysAgo = new Date();
|
||||
thirtyDaysAgo.setDate(today.getDate() - 30);
|
||||
@@ -98,10 +99,20 @@ const ChartSwitcher: React.FC<ChartSwitcherProps> = ({ isOpen, onClose }) => {
|
||||
dispatch(setVonDatum(toISO(thirtyDaysAgo)));
|
||||
dispatch(setBisDatum(toISO(today)));
|
||||
|
||||
// Warten, bis Redux gesetzt ist → dann Daten laden
|
||||
setTimeout(() => {
|
||||
loadLoopChartData.loadLoopChartData();
|
||||
}, 10); // kleiner Delay, damit Redux-State sicher aktualisiert ist
|
||||
// Set SlotType based on activeMode
|
||||
if (activeMode === "ISO") {
|
||||
dispatch(setSelectedSlotType("isolationswiderstand"));
|
||||
} else if (activeMode === "Schleife") {
|
||||
dispatch(setSelectedSlotType("schleifenwiderstand"));
|
||||
}
|
||||
|
||||
// Load data for Schleife mode
|
||||
if (activeMode === "Schleife" && slotNumber !== null) {
|
||||
// Warten, bis Redux gesetzt ist → dann Daten laden
|
||||
setTimeout(() => {
|
||||
loadLoopChartData.loadLoopChartData();
|
||||
}, 10); // kleiner Delay, damit Redux-State sicher aktualisiert ist
|
||||
}
|
||||
}
|
||||
//ESLint ignore
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
@@ -187,6 +198,14 @@ const ChartSwitcher: React.FC<ChartSwitcherProps> = ({ isOpen, onClose }) => {
|
||||
<LoopMeasurementChart />
|
||||
</div>
|
||||
</>
|
||||
) : activeMode === "ISO" ? (
|
||||
<>
|
||||
<h3 className="text-lg font-semibold">Isolationswiderstand</h3>
|
||||
<LoopChartActionBar />
|
||||
<div style={{ flex: 1, height: "90%" }}>
|
||||
<IsoMeasurementChart />
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<h3 className="text-lg font-semibold">TDR-Messung</h3>
|
||||
|
||||
Reference in New Issue
Block a user