cleanup: alte GIS-Fetch-Dateien und unnötige Service-Imports entfernt – vollständige Umstellung auf zentrale Thunks abgeschlossen
This commit is contained in:
31
redux/slices/database/locationDevicesSlice.js
Normal file
31
redux/slices/database/locationDevicesSlice.js
Normal file
@@ -0,0 +1,31 @@
|
||||
// /redux/slices/database/locationDevicesSlice.js
|
||||
|
||||
import { createSlice } from "@reduxjs/toolkit";
|
||||
import { fetchLocationDevicesThunk } from "../../../thunks/fetchLocationDevicesThunk";
|
||||
|
||||
const slice = createSlice({
|
||||
name: "locationDevices",
|
||||
initialState: {
|
||||
data: [],
|
||||
status: "idle",
|
||||
error: null,
|
||||
},
|
||||
reducers: {},
|
||||
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 default slice.reducer;
|
||||
export const selectLocationDevices = (state) => state.locationDevices.data;
|
||||
Reference in New Issue
Block a user