fix: KÜ slotnummer in der Messkurven Modal

This commit is contained in:
ISA
2025-07-28 08:29:48 +02:00
parent f79c225b71
commit 7a9fbc97dd
23 changed files with 6399 additions and 9193 deletions

View File

@@ -4,7 +4,11 @@ import { useSelector } from "react-redux";
import KueModal from "./modals/SettingsModalWrapper";
import "bootstrap-icons/font/bootstrap-icons.css"; // Import Bootstrap Icons
import { Kue705FOProps } from "../../../../types/Kue705FOProps";
// Keep ChartSwitcher import
import ChartSwitcher from "./Charts/ChartSwitcher";
// Remove separate chart imports since we use ChartSwitcher
// import IsoMeasurementChart from "./Charts/IsoMeasurementChart/IsoMeasurementChart";
// import LoopMeasurementChart from "./Charts/LoopMeasurementChart/LoopMeasurementChart";
//-------Redux Toolkit--------
import { RootState } from "../../../../redux/store";
import { useDispatch } from "react-redux";
@@ -19,13 +23,13 @@ import useModulName from "./hooks/useModulName";
import type { Chart } from "chart.js";
//--------handlers----------------
import handleButtonClick from "./kue705FO-Funktionen/handleButtonClick";
// Keep needed imports
import handleOpenModal from "./handlers/handleOpenModal";
import handleCloseModal from "./handlers/handleCloseModal";
// Restore chart modal handlers
import handleOpenChartModal from "./handlers/handleOpenChartModal";
import handleCloseChartModal from "./handlers/handleCloseChartModal";
import handleRefreshClick from "./handlers/handleRefreshClick";
import FallSensors from "@/components/main/fall-detection-sensors/FallSensors";
const Kue705FO: React.FC<Kue705FOProps> = ({
isolationswert,
@@ -43,7 +47,7 @@ const Kue705FO: React.FC<Kue705FOProps> = ({
const dispatch = useDispatch();
const { kueName } = useSelector((state: RootState) => state.kueDataSlice);
const [activeButton, setActiveButton] = useState<"Schleife" | "TDR">(
const [activeButton, setActiveButton] = useState<"Schleife" | "TDR" | "ISO">(
"Schleife"
);
@@ -59,7 +63,11 @@ const Kue705FO: React.FC<Kue705FOProps> = ({
const [loading, setLoading] = useState(false);
const [showModal, setShowModal] = useState(false);
// Keep original showChartModal
const [showChartModal, setShowChartModal] = useState(false);
// Remove separate modals since we use ChartSwitcher
// const [showIsoModal, setShowIsoModal] = useState(false);
// const [showRslModal, setShowRslModal] = useState(false);
// Removed unused loopMeasurementCurveChartData state
//------- Redux-Variablen abrufen--------------------------------
@@ -98,11 +106,40 @@ const Kue705FO: React.FC<Kue705FOProps> = ({
//-------------------------handlers-------------------------
const openModal = () => handleOpenModal(setShowModal);
const closeModal = () => handleCloseModal(setShowModal);
const openChartModal = () =>
handleOpenChartModal(setShowChartModal, dispatch, slotIndex, activeButton);
// Restore original chart modal handlers but set chart type automatically
const openIsoModal = () => {
setActiveButton("ISO");
// Set Redux state for ISO type
dispatch({
type: "kabelueberwachungChart/setSelectedSlotType",
payload: 1, // 1 = Isolationswiderstand
});
dispatch({
type: "kabelueberwachungChart/setSlotNumber",
payload: slotIndex,
});
// Open chart modal with ISO type
handleOpenChartModal(setShowChartModal, dispatch, slotIndex, "ISO");
};
const openRslModal = () => {
setActiveButton("Schleife");
setloopTitleText("Schleifenwiderstand [kOhm]");
setLoopDisplayValue(Number(schleifenwiderstand));
dispatch({
type: "kabelueberwachungChart/setSelectedSlotType",
payload: 2,
}); // RSL type
dispatch({
type: "kabelueberwachungChart/setSlotNumber",
payload: slotIndex,
});
handleOpenChartModal(setShowChartModal, dispatch, slotIndex, "Schleife");
};
const refreshClick = () =>
handleRefreshClick(activeButton, slotIndex, setLoading);
// Create a ref for the chart instance to pass as the second argument
const chartInstance = useRef<Chart | null>(null);
const closeChartModal = () =>
@@ -371,33 +408,13 @@ const Kue705FO: React.FC<Kue705FOProps> = ({
{/* ISO and RSL Buttons */}
<div className="flex space-x-2">
<button
onClick={() => {
setActiveButton("Schleife");
setloopTitleText("Schleifenwiderstand [kOhm]");
setLoopDisplayValue(Number(schleifenwiderstand));
handleOpenChartModal(
setShowChartModal,
dispatch,
slotIndex,
"Schleife"
);
}}
onClick={openIsoModal}
className="bg-littwin-blue text-white text-[0.625rem] flex items-center justify-center p-2"
>
ISO
</button>
<button
onClick={() => {
setActiveButton("Schleife");
setloopTitleText("Schleifenwiderstand [kOhm]");
setLoopDisplayValue(Number(schleifenwiderstand));
handleOpenChartModal(
setShowChartModal,
dispatch,
slotIndex,
"Schleife"
);
}}
onClick={openRslModal}
className="bg-littwin-blue text-white text-[0.625rem] flex items-center justify-center p-2"
>
RSL
@@ -433,10 +450,7 @@ const Kue705FO: React.FC<Kue705FOProps> = ({
>
TDR
</button>
<button
onClick={openChartModal}
className="bg-littwin-blue text-white text-[0.625rem] flex items-center justify-center p-2"
>
<button className="bg-littwin-blue text-white text-[0.625rem] flex items-center justify-center p-2">
KVz
</button>
</div>
@@ -447,7 +461,7 @@ const Kue705FO: React.FC<Kue705FOProps> = ({
<div className="flex flex-col space-y-2 w-full"></div>
</div>
{/* Modal für Messkurve */}
{/* Original Modal für Messkurve with ChartSwitcher */}
{showChartModal && (
<ChartSwitcher
isOpen={showChartModal}