refactor: GIS-Redux-Slices reduziert auf 4 (statt 5) – veraltete Slices und Thunks entfernt, Code bereinigt
This commit is contained in:
@@ -1,29 +1,28 @@
|
||||
// /redux/slices/webService/gisStationsStaticDistrictSlice.js
|
||||
// redux/slices/webService/gisStationsStaticDistrictSlice.js
|
||||
|
||||
import { createSlice, createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { fetchGisStationsStaticDistrict } from "../../api/fromWebService/fetchGisStationsStaticDistrict";
|
||||
import { fetchGisStationsStaticDistrictService } from "../../../services/webservice/fetchGisStationsStaticDistrictService";
|
||||
|
||||
export const fetchGisStationsStaticDistrictFromWebService = createAsyncThunk("gisStationsStaticDistrict/fetchGisStationsStaticDistrictFromWebService", async () => {
|
||||
return fetchGisStationsStaticDistrict();
|
||||
});
|
||||
import { fetchGisStationsStaticDistrictThunk } from "../../thunks/fetchGisStationsStaticDistrictThunk";
|
||||
|
||||
const gisStationsStaticDistrictSlice = createSlice({
|
||||
const slice = createSlice({
|
||||
name: "gisStationsStaticDistrict",
|
||||
initialState: {
|
||||
data: [],
|
||||
data: { Points: [] }, // Daten als Objekt mit Points-Array
|
||||
status: "idle",
|
||||
error: null,
|
||||
},
|
||||
reducers: {},
|
||||
extraReducers: (builder) => {
|
||||
builder
|
||||
.addCase(fetchGisStationsStaticDistrictFromWebService.pending, (state) => {
|
||||
.addCase(fetchGisStationsStaticDistrictThunk.pending, (state) => {
|
||||
state.status = "loading";
|
||||
})
|
||||
.addCase(fetchGisStationsStaticDistrictFromWebService.fulfilled, (state, action) => {
|
||||
.addCase(fetchGisStationsStaticDistrictThunk.fulfilled, (state, action) => {
|
||||
state.status = "succeeded";
|
||||
state.data = action.payload;
|
||||
state.data = { Points: action.payload }; // kompatibel mit Zugriff .Points
|
||||
})
|
||||
.addCase(fetchGisStationsStaticDistrictFromWebService.rejected, (state, action) => {
|
||||
.addCase(fetchGisStationsStaticDistrictThunk.rejected, (state, action) => {
|
||||
state.status = "failed";
|
||||
state.error = action.error.message;
|
||||
});
|
||||
@@ -31,5 +30,4 @@ const gisStationsStaticDistrictSlice = createSlice({
|
||||
});
|
||||
|
||||
export const selectGisStationsStaticDistrict = (state) => state.gisStationsStaticDistrict.data;
|
||||
|
||||
export default gisStationsStaticDistrictSlice.reducer;
|
||||
export default slice.reducer;
|
||||
|
||||
Reference in New Issue
Block a user