Linien werden angezeigt aber noch nicht mit Daten von Redux Store sondern direkt fetch Aufruf
This commit is contained in:
29
redux/slices/database/gisLinesSlice.js
Normal file
29
redux/slices/database/gisLinesSlice.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import { createSlice } from "@reduxjs/toolkit";
|
||||
import { fetchGisLinesThunk } from "../../thunks/database/fetchGisLinesThunk";
|
||||
|
||||
const gisLinesSlice = createSlice({
|
||||
name: "gisLines",
|
||||
initialState: {
|
||||
data: [],
|
||||
status: "idle",
|
||||
error: null,
|
||||
},
|
||||
reducers: {},
|
||||
extraReducers: (builder) => {
|
||||
builder
|
||||
.addCase(fetchGisLinesThunk.pending, (state) => {
|
||||
state.status = "loading";
|
||||
})
|
||||
.addCase(fetchGisLinesThunk.fulfilled, (state, action) => {
|
||||
state.status = "succeeded";
|
||||
state.data = action.payload;
|
||||
})
|
||||
.addCase(fetchGisLinesThunk.rejected, (state, action) => {
|
||||
state.status = "failed";
|
||||
state.error = action.error.message;
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
export default gisLinesSlice.reducer;
|
||||
export const selectGisLines = (state) => state.gisLines.data;
|
||||
Reference in New Issue
Block a user