fix: korrigierter Redux-State für activeMode im ChartSwitcher
- useSelector-Aufruf in ChartSwitcher.tsx angepasst, um den korrekten Redux-Slice (kueChartMode) zu verwenden. - Fehler behoben: TypeError: Cannot read properties of undefined (reading 'activeMode').
This commit is contained in:
@@ -17,7 +17,7 @@ interface ChartSwitcherProps {
|
||||
const ChartSwitcher: React.FC<ChartSwitcherProps> = ({ isOpen, onClose }) => {
|
||||
const dispatch = useDispatch();
|
||||
const activeMode = useSelector(
|
||||
(state: RootState) => state.loopMeasurementCurveChartData.activeMode
|
||||
(state: RootState) => state.kueChartMode.activeMode
|
||||
);
|
||||
|
||||
// **Neue Funktion: Modal schließen + Redux-Status zurücksetzen**
|
||||
|
||||
@@ -20,7 +20,7 @@ import { loadTDRChartData } from "../../../../utils/loadTDRChartData";
|
||||
import { loadLoopChartData } from "../../../../utils/loadLoopChartData";
|
||||
import { Kue705FOProps } from "../../../../types/components/Kue705FOProps";
|
||||
import ChartSwitcher from "./Charts/ChartSwitcher";
|
||||
import { setActiveMode } from "../../../../redux/slices/chartDataSlice";
|
||||
import { setActiveMode } from "../../../../redux/slices/kueChartModeSlice";
|
||||
import LoopMeasurementChart from "./Charts/LoopMeasurementChart/LoopMeasurementChart";
|
||||
import TDRChart from "./Charts/TDRChart/TDRChart";
|
||||
import handleButtonClick from "./kue705FO-Funktionen/handleButtonClick";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// components/main/kabelueberwachung/kue705FO/kue705FO-Funktionen/handleButtonClick.ts
|
||||
import { Dispatch } from "react";
|
||||
import { setActiveMode } from "../../../../../redux/slices/chartDataSlice";
|
||||
import { setActiveMode } from "../../../../../redux/slices/kueChartModeSlice";
|
||||
|
||||
const handleButtonClick = (
|
||||
button: "Schleife" | "TDR",
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||
|
||||
interface ChartDataState {
|
||||
data: any[];
|
||||
activeMode: "Schleife" | "TDR"; // 🔥 Neuer Zustand für den aktiven Modus
|
||||
}
|
||||
|
||||
const initialState: ChartDataState = {
|
||||
data: [],
|
||||
activeMode: "Schleife", // Standard ist Schleife
|
||||
};
|
||||
|
||||
export const chartDataSlice = createSlice({
|
||||
name: "loopMeasurementCurveChartData",
|
||||
initialState,
|
||||
reducers: {
|
||||
setLoopMeasurementCurveChartData: (state, action: PayloadAction<any[]>) => {
|
||||
state.data = action.payload;
|
||||
},
|
||||
clearChartData: (state) => {
|
||||
state.data = [];
|
||||
},
|
||||
setActiveMode: (state, action: PayloadAction<"Schleife" | "TDR">) => {
|
||||
state.activeMode = action.payload; // 🔥 Speichert den Modus (Schleife oder TDR)
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const {
|
||||
setLoopMeasurementCurveChartData,
|
||||
clearChartData,
|
||||
setActiveMode,
|
||||
} = chartDataSlice.actions;
|
||||
export default chartDataSlice.reducer;
|
||||
23
redux/slices/kueChartModeSlice.ts
Normal file
23
redux/slices/kueChartModeSlice.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
// /redux/slices/kueChartModeSlice.ts
|
||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||
|
||||
interface KueChartModeState {
|
||||
activeMode: "Schleife" | "TDR"; // 🔥 Neuer Zustand für den aktiven Modus
|
||||
}
|
||||
|
||||
const initialState: KueChartModeState = {
|
||||
activeMode: "Schleife", // Standard ist Schleife
|
||||
};
|
||||
|
||||
export const kueChartModeSlice = createSlice({
|
||||
name: "kueChartMode",
|
||||
initialState,
|
||||
reducers: {
|
||||
setActiveMode: (state, action: PayloadAction<"Schleife" | "TDR">) => {
|
||||
state.activeMode = action.payload; // 🔥 Speichert den Modus (Schleife oder TDR)
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const { setActiveMode } = kueChartModeSlice.actions;
|
||||
export default kueChartModeSlice.reducer;
|
||||
@@ -2,7 +2,7 @@
|
||||
import { configureStore } from "@reduxjs/toolkit";
|
||||
import authReducer from "./slices/authSlice";
|
||||
import variablesReducer from "./slices/variablesSlice";
|
||||
import chartDataReducer from "./slices/chartDataSlice";
|
||||
import kueChartModeReducer from "./slices/kueChartModeSlice";
|
||||
import webVersionReducer from "./slices/webVersionSlice";
|
||||
import digitalInputsReducer from "./slices/digitalInputsSlice";
|
||||
import kabelueberwachungChartReducer from "./slices/kabelueberwachungChartSlice";
|
||||
@@ -11,7 +11,7 @@ const store = configureStore({
|
||||
reducer: {
|
||||
auth: authReducer,
|
||||
variables: variablesReducer,
|
||||
loopMeasurementCurveChartData: chartDataReducer,
|
||||
kueChartMode: kueChartModeReducer,
|
||||
webVersion: webVersionReducer,
|
||||
digitalInputs: digitalInputsReducer,
|
||||
kabelueberwachungChart: kabelueberwachungChartReducer,
|
||||
|
||||
Reference in New Issue
Block a user