33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
// redux/slices/webService/gisStationsStaticDistrictSlice.js
|
|
|
|
import { createSlice } from "@reduxjs/toolkit";
|
|
|
|
import { fetchGisStationsStaticDistrictThunk } from "../../thunks/webservice/fetchGisStationsStaticDistrictThunk";
|
|
|
|
const slice = createSlice({
|
|
name: "gisStationsStaticDistrict",
|
|
initialState: {
|
|
data: { Points: [] }, // Daten als Objekt mit Points-Array
|
|
status: "idle",
|
|
error: null,
|
|
},
|
|
reducers: {},
|
|
extraReducers: (builder) => {
|
|
builder
|
|
.addCase(fetchGisStationsStaticDistrictThunk.pending, (state) => {
|
|
state.status = "loading";
|
|
})
|
|
.addCase(fetchGisStationsStaticDistrictThunk.fulfilled, (state, action) => {
|
|
state.status = "succeeded";
|
|
state.data = { Points: action.payload }; // kompatibel mit Zugriff .Points
|
|
})
|
|
.addCase(fetchGisStationsStaticDistrictThunk.rejected, (state, action) => {
|
|
state.status = "failed";
|
|
state.error = action.error.message;
|
|
});
|
|
},
|
|
});
|
|
|
|
export const selectGisStationsStaticDistrict = (state) => state.gisStationsStaticDistrict.data;
|
|
export default slice.reducer;
|