// /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;