refactor: GIS-Redux-Slices reduziert auf 4 (statt 5) – veraltete Slices und Thunks entfernt, Code bereinigt
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
// /redux/slices/webService/gisStationsStatusDistrictSlice.js
|
||||
|
||||
import { createSlice, createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { fetchGisStationsStatusDistrict } from "../../api/fromWebService/fetchGisStationsStatusDistrict";
|
||||
import { fetchGisStationsStatusDistrictService } from "../../../services/webservice/fetchGisStationsStatusDistrictService";
|
||||
|
||||
export const fetchGisStationsStatusDistrictFromWebService = createAsyncThunk("gisStationsStatusDistrict/fetchGisStationsStatusDistrictFromWebService", async () => {
|
||||
return fetchGisStationsStatusDistrict();
|
||||
});
|
||||
import { fetchGisStationsStatusDistrictThunk } from "../../thunks/fetchGisStationsStatusDistrictThunk";
|
||||
|
||||
const gisStationsStatusDistrictSlice = createSlice({
|
||||
const slice = createSlice({
|
||||
name: "gisStationsStatusDistrict",
|
||||
initialState: {
|
||||
data: [],
|
||||
@@ -16,20 +15,19 @@ const gisStationsStatusDistrictSlice = createSlice({
|
||||
reducers: {},
|
||||
extraReducers: (builder) => {
|
||||
builder
|
||||
.addCase(fetchGisStationsStatusDistrictFromWebService.pending, (state) => {
|
||||
.addCase(fetchGisStationsStatusDistrictThunk.pending, (state) => {
|
||||
state.status = "loading";
|
||||
})
|
||||
.addCase(fetchGisStationsStatusDistrictFromWebService.fulfilled, (state, action) => {
|
||||
.addCase(fetchGisStationsStatusDistrictThunk.fulfilled, (state, action) => {
|
||||
state.status = "succeeded";
|
||||
state.data = action.payload;
|
||||
})
|
||||
.addCase(fetchGisStationsStatusDistrictFromWebService.rejected, (state, action) => {
|
||||
.addCase(fetchGisStationsStatusDistrictThunk.rejected, (state, action) => {
|
||||
state.status = "failed";
|
||||
state.error = action.error.message;
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
export default slice.reducer;
|
||||
export const selectGisStationsStatusDistrict = (state) => state.gisStationsStatusDistrict.data;
|
||||
|
||||
export default gisStationsStatusDistrictSlice.reducer;
|
||||
|
||||
Reference in New Issue
Block a user