feat: APIs erstellt für Systemspannungen
This commit is contained in:
50
redux/slices/systemspannung15VplusSlice.ts
Normal file
50
redux/slices/systemspannung15VplusSlice.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||
import { getSystemspannung15VplusThunk } from "../thunks/getSystemspannung15VplusThunk";
|
||||
|
||||
type StateType = {
|
||||
DIA0: unknown[];
|
||||
DIA1: unknown[];
|
||||
DIA2: unknown[];
|
||||
isLoading: boolean;
|
||||
error: string | null;
|
||||
};
|
||||
|
||||
const initialState: StateType = {
|
||||
DIA0: [],
|
||||
DIA1: [],
|
||||
DIA2: [],
|
||||
isLoading: false,
|
||||
error: null,
|
||||
};
|
||||
|
||||
export const systemspannung15VplusSlice = createSlice({
|
||||
name: "systemspannung15Vplus",
|
||||
initialState,
|
||||
reducers: {},
|
||||
extraReducers: (builder) => {
|
||||
builder
|
||||
.addCase(getSystemspannung15VplusThunk.pending, (state) => {
|
||||
state.isLoading = true;
|
||||
state.error = null;
|
||||
})
|
||||
.addCase(
|
||||
getSystemspannung15VplusThunk.fulfilled,
|
||||
(
|
||||
state,
|
||||
action: PayloadAction<{
|
||||
typ: "DIA0" | "DIA1" | "DIA2";
|
||||
data: unknown[];
|
||||
}>
|
||||
) => {
|
||||
state.isLoading = false;
|
||||
state[action.payload.typ] = action.payload.data;
|
||||
}
|
||||
)
|
||||
.addCase(getSystemspannung15VplusThunk.rejected, (state, action) => {
|
||||
state.isLoading = false;
|
||||
state.error = action.payload as string;
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
export default systemspannung15VplusSlice.reducer;
|
||||
Reference in New Issue
Block a user