feat: AnalogInputsChart mit DateRangePicker und vollständiger Redux-Integration erweitert
- analogInputsHistorySlice angepasst: zeitraum, vonDatum, bisDatum und data hinzugefügt - Typdefinitionen im Slice und Thunk korrigiert - getAnalogInputsHistoryThunk erweitert, um vonDatum und bisDatum zu akzeptieren - DateRangePicker korrekt in AnalogInputsChart.tsx integriert - Fehler bei Selector-Zugriffen und Dispatch behoben
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||
|
||||
export type Zeitraum = "DIA0" | "DIA1" | "DIA2";
|
||||
|
||||
interface ChartState {
|
||||
zeitraum: Zeitraum;
|
||||
vonDatum: string;
|
||||
bisDatum: string;
|
||||
isLoading: boolean;
|
||||
}
|
||||
|
||||
const initialState: ChartState = {
|
||||
zeitraum: "DIA0",
|
||||
vonDatum: "",
|
||||
bisDatum: "",
|
||||
isLoading: false,
|
||||
};
|
||||
|
||||
const analogInputsChartSlice = createSlice({
|
||||
name: "analogInputsChart",
|
||||
initialState,
|
||||
reducers: {
|
||||
setZeitraum: (state, action: PayloadAction<Zeitraum>) => {
|
||||
state.zeitraum = action.payload;
|
||||
},
|
||||
setVonDatum: (state, action: PayloadAction<string>) => {
|
||||
state.vonDatum = action.payload;
|
||||
},
|
||||
setBisDatum: (state, action: PayloadAction<string>) => {
|
||||
state.bisDatum = action.payload;
|
||||
},
|
||||
setIsLoading: (state, action: PayloadAction<boolean>) => {
|
||||
state.isLoading = action.payload;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const { setZeitraum, setVonDatum, setBisDatum, setIsLoading } =
|
||||
analogInputsChartSlice.actions;
|
||||
export default analogInputsChartSlice.reducer;
|
||||
@@ -1,4 +1,3 @@
|
||||
// /redux/slices/analogInputsHistorySlice.ts
|
||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||
import { getAnalogInputsHistoryThunk } from "../thunks/getAnalogInputsHistoryThunk";
|
||||
|
||||
@@ -7,27 +6,37 @@ export type AnalogInputsHistoryEntry = {
|
||||
m: number;
|
||||
};
|
||||
|
||||
interface AnalogInputsHistoryState {
|
||||
data: Record<string, AnalogInputsHistoryEntry[]>;
|
||||
export interface InputHistoryState {
|
||||
zeitraum: string;
|
||||
vonDatum: string;
|
||||
bisDatum: string;
|
||||
isLoading: boolean;
|
||||
error: string | null;
|
||||
zeitraum: string; // z.B. "DIA0", "DIA1", "DIA2"
|
||||
data: Record<string, AnalogInputsHistoryEntry[]>;
|
||||
}
|
||||
|
||||
const initialState: AnalogInputsHistoryState = {
|
||||
data: {},
|
||||
const initialState: InputHistoryState = {
|
||||
zeitraum: "DIA0",
|
||||
vonDatum: "",
|
||||
bisDatum: "",
|
||||
isLoading: false,
|
||||
error: null,
|
||||
zeitraum: "DIA0",
|
||||
data: {},
|
||||
};
|
||||
|
||||
const analogInputsHistorySlice = createSlice({
|
||||
export const analogInputsHistorySlice = createSlice({
|
||||
name: "analogInputsHistory",
|
||||
initialState,
|
||||
reducers: {
|
||||
setZeitraum: (state, action: PayloadAction<string>) => {
|
||||
state.zeitraum = action.payload;
|
||||
},
|
||||
setVonDatum: (state, action: PayloadAction<string>) => {
|
||||
state.vonDatum = action.payload;
|
||||
},
|
||||
setBisDatum: (state, action: PayloadAction<string>) => {
|
||||
state.bisDatum = action.payload;
|
||||
},
|
||||
},
|
||||
extraReducers: (builder) => {
|
||||
builder
|
||||
@@ -35,22 +44,11 @@ const analogInputsHistorySlice = createSlice({
|
||||
state.isLoading = true;
|
||||
state.error = null;
|
||||
})
|
||||
.addCase(
|
||||
getAnalogInputsHistoryThunk.fulfilled,
|
||||
(
|
||||
state,
|
||||
action: PayloadAction<{
|
||||
eingang: number;
|
||||
zeitraum: string;
|
||||
daten: AnalogInputsHistoryEntry[];
|
||||
}>
|
||||
) => {
|
||||
const key = String(action.payload.eingang + 99); // z.B. 100 für AE1
|
||||
state.data[key] = action.payload.daten;
|
||||
state.zeitraum = action.payload.zeitraum;
|
||||
state.isLoading = false;
|
||||
}
|
||||
)
|
||||
.addCase(getAnalogInputsHistoryThunk.fulfilled, (state, action) => {
|
||||
const key = String(action.payload.eingang + 99);
|
||||
state.data[key] = action.payload.daten;
|
||||
state.isLoading = false;
|
||||
})
|
||||
.addCase(getAnalogInputsHistoryThunk.rejected, (state, action) => {
|
||||
state.isLoading = false;
|
||||
state.error = action.payload as string;
|
||||
@@ -58,6 +56,7 @@ const analogInputsHistorySlice = createSlice({
|
||||
},
|
||||
});
|
||||
|
||||
export const { setZeitraum } = analogInputsHistorySlice.actions;
|
||||
export const { setZeitraum, setVonDatum, setBisDatum } =
|
||||
analogInputsHistorySlice.actions;
|
||||
|
||||
export default analogInputsHistorySlice.reducer;
|
||||
|
||||
Reference in New Issue
Block a user