fix(poi): Fehler beim Hinzufügen von POIs behoben (Modal blieb offen)
- Falsche URL im addPoiService korrigiert (/addLocation → /addPoi) - Redux-Status wird nach erfolgreichem Hinzufügen zurückgesetzt (resetAddPoiStatus) - Modal schließt jetzt zuverlässig nach dem Dispatch - Ladeanzeige "Wird hinzugefügt..." verschwindet korrekt - Version auf 1.1.176 erhöht
This commit is contained in:
44
redux/slices/database/pois/poiMarkersSlice.js
Normal file
44
redux/slices/database/pois/poiMarkersSlice.js
Normal file
@@ -0,0 +1,44 @@
|
||||
// /redux/slices/database/pois/poiMarkersSlice.js
|
||||
import { createSlice } from "@reduxjs/toolkit";
|
||||
import { fetchPoiMarkersThunk } from "../../../thunks/database/pois/fetchPoiMarkersThunk";
|
||||
|
||||
const initialState = {
|
||||
data: [],
|
||||
status: "idle",
|
||||
error: null,
|
||||
};
|
||||
|
||||
const poiMarkersSlice = createSlice({
|
||||
name: "poiMarkers",
|
||||
initialState,
|
||||
reducers: {
|
||||
setPoiMarkers: (state, action) => {
|
||||
state.data = action.payload;
|
||||
},
|
||||
clearPoiMarkers: (state) => {
|
||||
state.data = [];
|
||||
},
|
||||
},
|
||||
extraReducers: (builder) => {
|
||||
builder
|
||||
.addCase(fetchPoiMarkersThunk.pending, (state) => {
|
||||
state.status = "loading";
|
||||
})
|
||||
.addCase(fetchPoiMarkersThunk.fulfilled, (state, action) => {
|
||||
state.status = "succeeded";
|
||||
state.data = action.payload;
|
||||
})
|
||||
.addCase(fetchPoiMarkersThunk.rejected, (state, action) => {
|
||||
state.status = "failed";
|
||||
state.error = action.error.message;
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
export const { setPoiMarkers, clearPoiMarkers } = poiMarkersSlice.actions;
|
||||
|
||||
export const selectPoiMarkers = (state) => state.poiMarkers.data;
|
||||
export const selectPoiMarkersStatus = (state) => state.poiMarkers.status;
|
||||
export const selectPoiMarkersError = (state) => state.poiMarkers.error;
|
||||
|
||||
export default poiMarkersSlice.reducer;
|
||||
@@ -11,6 +11,7 @@ import selectedPoiReducer from "./slices/database/pois/selectedPoiSlice";
|
||||
import currentPoiReducer from "./slices/database/pois/currentPoiSlice";
|
||||
import poiReadFromDbTriggerReducer from "./slices/database/pois/poiReadFromDbTriggerSlice";
|
||||
import readPoiMarkersStoreReducer from "./slices/database/pois/readPoiMarkersStoreSlice";
|
||||
import poiMarkersReducer from "./slices/database/pois/poiMarkersSlice";
|
||||
//--polylines------------
|
||||
import gisLinesFromDatabaseReducer from "./slices/database/polylines/gisLinesSlice";
|
||||
import polylineLayerVisibleReducer from "./slices/database/polylines/polylineLayerVisibleSlice";
|
||||
@@ -66,5 +67,6 @@ export const store = configureStore({
|
||||
addPoi: addPoiReducer,
|
||||
poiTyp: poiTypReducer,
|
||||
poiIconsData: poiIconsDataReducer,
|
||||
poiMarkers: poiMarkersReducer,
|
||||
},
|
||||
});
|
||||
|
||||
8
redux/thunks/database/pois/fetchPoiMarkersThunk.js
Normal file
8
redux/thunks/database/pois/fetchPoiMarkersThunk.js
Normal file
@@ -0,0 +1,8 @@
|
||||
// /redux/thunks/database/pois/fetchPoiMarkersThunk.js
|
||||
import { createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { fetchPoiMarkersService } from "../../../../services/database/pois/fetchPoiMarkersService";
|
||||
|
||||
// Einheitlicher Name passend zur Slice-Datei
|
||||
export const fetchPoiMarkersThunk = createAsyncThunk("poiMarkers/fetchAll", async () => {
|
||||
return await fetchPoiMarkersService();
|
||||
});
|
||||
Reference in New Issue
Block a user