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;
|
||||
Reference in New Issue
Block a user