refactor: fetchLocationDevices.js entfernt – Nutzung über Thunk + Service strukturiert neu aufgesetzt
This commit is contained in:
@@ -1,10 +1,5 @@
|
||||
// /redux/slices/database/locationDevicesFromDBSlice.js
|
||||
import { createSlice, createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { fetchLocationDevices } from "../../api/fromDB/fetchLocationDevices";
|
||||
|
||||
export const fetchLocationDevicesFromDB = createAsyncThunk("locationDevicesFromDB/fetchLocationDevicesFromDB", async () => {
|
||||
return fetchLocationDevices();
|
||||
});
|
||||
import { createSlice } from "@reduxjs/toolkit";
|
||||
import { fetchLocationDevicesThunk } from "../../thunks/database/fetchLocationDevicesThunk";
|
||||
|
||||
const locationDevicesFromDBSlice = createSlice({
|
||||
name: "locationDevicesFromDB",
|
||||
@@ -16,14 +11,14 @@ const locationDevicesFromDBSlice = createSlice({
|
||||
reducers: {},
|
||||
extraReducers: (builder) => {
|
||||
builder
|
||||
.addCase(fetchLocationDevicesFromDB.pending, (state) => {
|
||||
.addCase(fetchLocationDevicesThunk.pending, (state) => {
|
||||
state.status = "loading";
|
||||
})
|
||||
.addCase(fetchLocationDevicesFromDB.fulfilled, (state, action) => {
|
||||
.addCase(fetchLocationDevicesThunk.fulfilled, (state, action) => {
|
||||
state.status = "succeeded";
|
||||
state.devices = action.payload; // <-- Hier landen die Daten
|
||||
state.devices = action.payload;
|
||||
})
|
||||
.addCase(fetchLocationDevicesFromDB.rejected, (state, action) => {
|
||||
.addCase(fetchLocationDevicesThunk.rejected, (state, action) => {
|
||||
state.status = "failed";
|
||||
state.error = action.error.message;
|
||||
});
|
||||
@@ -31,3 +26,4 @@ const locationDevicesFromDBSlice = createSlice({
|
||||
});
|
||||
|
||||
export default locationDevicesFromDBSlice.reducer;
|
||||
export const selectLocationDevices = (state) => state.locationDevicesFromDB.devices;
|
||||
|
||||
Reference in New Issue
Block a user