refactor: Code-Struktur verbessert, Handler und Logik modularisiert
- Alle Event-Handler in eigene Dateien ausgelagert: - `handleOpenModal.ts`, `handleCloseModal.ts` - `handleOpenChartModal.ts`, `handleCloseChartModal.ts` - `handleRefreshClick.ts`, `handleSave.ts` - Neue Hooks zur Verwaltung von Redux-Selektoren und UI-Zuständen erstellt - `Kue705FO.tsx` gesäubert, jetzt schlanker und übersichtlicher - Verbesserte Wartbarkeit und Wiederverwendbarkeit der Code-Basis
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
// components/main/kabelueberwachung/kue705FO/handlers/handleCloseChartModal.ts
|
||||
const handleCloseChartModal = (
|
||||
setShowChartModal: (value: boolean) => void,
|
||||
chartInstance: any
|
||||
) => {
|
||||
if (chartInstance.current) {
|
||||
console.log("Chart wird beim Schließen des Modals zerstört.");
|
||||
chartInstance.current.destroy();
|
||||
chartInstance.current = null;
|
||||
}
|
||||
setShowChartModal(false);
|
||||
};
|
||||
|
||||
export default handleCloseChartModal;
|
||||
@@ -0,0 +1,6 @@
|
||||
// components/main/kabelueberwachung/kue705FO/handlers/handleCloseModal.ts
|
||||
const handleCloseModal = (setShowModal: (value: boolean) => void) => {
|
||||
setShowModal(false);
|
||||
};
|
||||
|
||||
export default handleCloseModal;
|
||||
@@ -0,0 +1,27 @@
|
||||
// components/main/kabelueberwachung/kue705FO/handlers/handleOpenChartModal.ts
|
||||
import { Dispatch, SetStateAction } from "react";
|
||||
import {
|
||||
setChartOpen,
|
||||
setSlotNumber,
|
||||
} from "../../../../../redux/slices/kabelueberwachungChartSlice";
|
||||
import { setActiveMode } from "../../../../../redux/slices/kueChartModeSlice";
|
||||
import { useDispatch } from "react-redux";
|
||||
|
||||
const handleOpenChartModal = (
|
||||
setShowChartModal: Dispatch<SetStateAction<boolean>>,
|
||||
dispatch: ReturnType<typeof useDispatch>,
|
||||
slotIndex: number,
|
||||
activeButton: "Schleife" | "TDR"
|
||||
) => {
|
||||
setShowChartModal(true);
|
||||
dispatch(setChartOpen(true));
|
||||
dispatch(setSlotNumber(slotIndex + 1));
|
||||
|
||||
if (activeButton === "TDR") {
|
||||
dispatch(setActiveMode("TDR"));
|
||||
} else {
|
||||
dispatch(setActiveMode("Schleife"));
|
||||
}
|
||||
};
|
||||
|
||||
export default handleOpenChartModal;
|
||||
@@ -0,0 +1,6 @@
|
||||
// components/main/kabelueberwachung/kue705FO/handlers/handleOpenModal.ts
|
||||
const handleOpenModal = (setShowModal: (value: boolean) => void) => {
|
||||
setShowModal(true);
|
||||
};
|
||||
|
||||
export default handleOpenModal;
|
||||
@@ -0,0 +1,18 @@
|
||||
// components/main/kabelueberwachung/kue705FO/handlers/handleRefreshClick.ts
|
||||
import { Dispatch, SetStateAction } from "react";
|
||||
import { goLoop } from "../../../../../utils/goLoop";
|
||||
import { goTDR } from "../../../../../utils/goTDR";
|
||||
|
||||
const handleRefreshClick = (
|
||||
activeButton: "Schleife" | "TDR",
|
||||
slotIndex: number,
|
||||
setLoading: Dispatch<SetStateAction<boolean>>
|
||||
) => {
|
||||
if (activeButton === "Schleife") {
|
||||
goLoop(slotIndex, setLoading);
|
||||
} else if (activeButton === "TDR") {
|
||||
goTDR(slotIndex, setLoading);
|
||||
}
|
||||
};
|
||||
|
||||
export default handleRefreshClick;
|
||||
Reference in New Issue
Block a user