fix: Messwertlinie (m) im DIA0-Modus in DetailModal sichtbar gemacht
This commit is contained in:
48
redux/slices/systemChartSlice.ts
Normal file
48
redux/slices/systemChartSlice.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
// /redux/slices/systemChartSlice.ts
|
||||
import { createSlice } from "@reduxjs/toolkit";
|
||||
import { getSystemChartDataThunk } from "@/redux/thunks/getSystemChartDataThunk";
|
||||
|
||||
interface ChartData {
|
||||
[mode: string]: {
|
||||
[type: number]: any;
|
||||
};
|
||||
}
|
||||
|
||||
interface SystemChartState {
|
||||
data: ChartData;
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
}
|
||||
|
||||
const initialState: SystemChartState = {
|
||||
data: {},
|
||||
loading: false,
|
||||
error: null,
|
||||
};
|
||||
|
||||
const systemChartSlice = createSlice({
|
||||
name: "systemChartSlice",
|
||||
initialState,
|
||||
reducers: {},
|
||||
extraReducers: (builder) => {
|
||||
builder
|
||||
.addCase(getSystemChartDataThunk.pending, (state) => {
|
||||
state.loading = true;
|
||||
state.error = null;
|
||||
})
|
||||
.addCase(getSystemChartDataThunk.fulfilled, (state, action) => {
|
||||
state.loading = false;
|
||||
const { mode, type } = action.meta.arg;
|
||||
if (!state.data[mode]) {
|
||||
state.data[mode] = {};
|
||||
}
|
||||
state.data[mode][type] = action.payload;
|
||||
})
|
||||
.addCase(getSystemChartDataThunk.rejected, (state, action) => {
|
||||
state.loading = false;
|
||||
state.error = action.payload as string;
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
export default systemChartSlice.reducer;
|
||||
@@ -38,6 +38,7 @@ import temperaturAdWandlerReducer from "./slices/temperaturAdWandlerSlice";
|
||||
import temperaturProzessorReducer from "./slices/temperaturProzessorSlice";
|
||||
import { combineReducers } from "@reduxjs/toolkit";
|
||||
import { useDispatch, useSelector, TypedUseSelectorHook } from "react-redux";
|
||||
import systemChartReducer from "./slices/systemChartSlice";
|
||||
|
||||
//---------------------------------------
|
||||
// 🧠 Nur diese Slices werden persistiert
|
||||
@@ -91,6 +92,7 @@ const rootReducer = combineReducers({
|
||||
firmwareUpdate: firmwareUpdateReducer,
|
||||
confirmModal: confirmModalReducer,
|
||||
firmwareProgress: firmwareProgressReducer,
|
||||
systemChartSlice: systemChartReducer,
|
||||
});
|
||||
|
||||
const persistedReducer = persistReducer(persistConfig, rootReducer);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// /redux/thunks/getLoopChartDataThunk.ts
|
||||
import { createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { fetchLoopChartData } from "../../services/fetchLoopChartDataService";
|
||||
import { fetchLoopChartData } from "@/services/fetchLoopChartDataService";
|
||||
|
||||
interface FetchLoopChartDataParams {
|
||||
mode: "DIA0" | "DIA1" | "DIA2";
|
||||
|
||||
35
redux/thunks/getSystemChartDataThunk.ts
Normal file
35
redux/thunks/getSystemChartDataThunk.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
// /redux/thunks/getSystemChartDataThunk.ts
|
||||
import { createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { fetchSystemChartData } from "@/services/fetchSystemChartDataService";
|
||||
|
||||
interface FetchSystemChartDataParams {
|
||||
mode: "DIA0" | "DIA1" | "DIA2";
|
||||
type: number;
|
||||
slotNumber: number;
|
||||
vonDatum: string;
|
||||
bisDatum: string;
|
||||
}
|
||||
|
||||
export const getSystemChartDataThunk = createAsyncThunk(
|
||||
"systemChart/fetchSystemChartData",
|
||||
async (params: FetchSystemChartDataParams, { rejectWithValue }) => {
|
||||
try {
|
||||
const data = await fetchSystemChartData(
|
||||
params.mode,
|
||||
params.type,
|
||||
params.slotNumber,
|
||||
params.vonDatum,
|
||||
params.bisDatum
|
||||
);
|
||||
|
||||
if (!data) {
|
||||
return rejectWithValue("Keine Daten erhalten");
|
||||
}
|
||||
|
||||
return data;
|
||||
} catch (error: any) {
|
||||
console.error("❌ Fehler in getSystemChartDataThunk:", error);
|
||||
return rejectWithValue(error.message || "Unbekannter Fehler");
|
||||
}
|
||||
}
|
||||
);
|
||||
Binary file not shown.
Reference in New Issue
Block a user