wip digitale Eingänge sind sichtbar aber keine Werte in Modal
This commit is contained in:
23
redux/thunks/fetchDigitalInputsThunk.ts
Normal file
23
redux/thunks/fetchDigitalInputsThunk.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
// @/redux/thunks/fetchDigitalInputsThunk.ts
|
||||
import { createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { fetchDigitalInputsService } from "@/services/fetchDigitalInputsService";
|
||||
import { setInputs } from "@/redux/slices/digitalInputsSlice";
|
||||
|
||||
/**
|
||||
* Holt digitale Eingänge von der API und speichert sie in Redux.
|
||||
*/
|
||||
export const fetchDigitalInputsThunk = createAsyncThunk(
|
||||
"digitalInputs/fetchDigitalInputs",
|
||||
async (_, { dispatch }) => {
|
||||
if (typeof window === "undefined") return;
|
||||
|
||||
try {
|
||||
const data = await fetchDigitalInputsService();
|
||||
if (data) {
|
||||
dispatch(setInputs(data)); // ✅ Redux mit API-Daten füllen
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("❌ Fehler beim Laden der digitalen Eingänge:", error);
|
||||
}
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user