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;
|
||||
Reference in New Issue
Block a user