- Redux-Slice `kabelueberwachungChartSlice.ts` erweitert um `selectedMode` und `selectedSlotType` - `LoopChartActionBar.tsx` so angepasst, dass Änderungen in den Dropdown-Menüs automatisch `handleFetchData` aufrufen - `useEffect` hinzugefügt, um Daten beim Wechsel von `selectedMode` oder `selectedSlotType` neu zu laden - Manuelles Klicken auf den "Daten Laden"-Button ist nun nicht mehr nötig
56 lines
1.4 KiB
TypeScript
56 lines
1.4 KiB
TypeScript
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
|
|
|
interface KabelueberwachungChartState {
|
|
chartData: any[];
|
|
vonDatum: string;
|
|
bisDatum: string;
|
|
selectedMode: "DIA0" | "DIA1" | "DIA2";
|
|
selectedSlotType: "isolationswiderstand" | "schleifenwiderstand";
|
|
}
|
|
|
|
const initialState: KabelueberwachungChartState = {
|
|
chartData: [],
|
|
vonDatum: "2025-02-01",
|
|
bisDatum: "2025-02-28",
|
|
selectedMode: "DIA0",
|
|
selectedSlotType: "schleifenwiderstand",
|
|
};
|
|
|
|
const kabelueberwachungChartSlice = createSlice({
|
|
name: "kabelueberwachungChart",
|
|
initialState,
|
|
reducers: {
|
|
setChartData: (state, action: PayloadAction<any[]>) => {
|
|
state.chartData = action.payload;
|
|
},
|
|
setVonDatum: (state, action: PayloadAction<string>) => {
|
|
state.vonDatum = action.payload;
|
|
},
|
|
setBisDatum: (state, action: PayloadAction<string>) => {
|
|
state.bisDatum = action.payload;
|
|
},
|
|
setSelectedMode: (
|
|
state,
|
|
action: PayloadAction<"DIA0" | "DIA1" | "DIA2">
|
|
) => {
|
|
state.selectedMode = action.payload;
|
|
},
|
|
setSelectedSlotType: (
|
|
state,
|
|
action: PayloadAction<"isolationswiderstand" | "schleifenwiderstand">
|
|
) => {
|
|
state.selectedSlotType = action.payload;
|
|
},
|
|
},
|
|
});
|
|
|
|
export const {
|
|
setChartData,
|
|
setVonDatum,
|
|
setBisDatum,
|
|
setSelectedMode,
|
|
setSelectedSlotType,
|
|
} = kabelueberwachungChartSlice.actions;
|
|
|
|
export default kabelueberwachungChartSlice.reducer;
|