- 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
45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
// /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;
|