Files
nodeMap/redux/slices/database/locationDevice/locationDevicesSlice.js
ISA 4c6386edea refactor(utils): saveLineData entfernt und durch Redux-Thunk ersetzt
- updatePolylineCoordinatesThunk in markerUtils.js und poiUtils.js eingebunden
- zentrale Hilfsfunktion savePolylineRedux erstellt
- fetch() entfernt, Version auf 1.1.183 erhöht
2025-05-27 08:33:02 +02:00

42 lines
1.2 KiB
JavaScript

// /redux/slices/database/locationDevice/locationDevicesSlice.js
import { createSlice } from "@reduxjs/toolkit";
import { fetchLocationDevicesThunk } from "../../../thunks/database/locationDevice/fetchLocationDevicesThunk";
const locationDevicesSlice = createSlice({
name: "locationDevices",
initialState: {
data: [],
status: "idle",
error: null,
},
reducers: {
clearLocationDevices: (state) => {
state.data = [];
state.status = "idle";
state.error = null;
},
},
extraReducers: (builder) => {
builder
.addCase(fetchLocationDevicesThunk.pending, (state) => {
state.status = "loading";
})
.addCase(fetchLocationDevicesThunk.fulfilled, (state, action) => {
state.status = "succeeded";
state.data = action.payload;
})
.addCase(fetchLocationDevicesThunk.rejected, (state, action) => {
state.status = "failed";
state.error = action.error.message;
});
},
});
export const { clearLocationDevices } = locationDevicesSlice.actions;
export const selectLocationDevices = (state) => state.locationDevices.data;
export const selectLocationDeviceStatus = (state) => state.locationDevices.status;
export default locationDevicesSlice.reducer;