chore: fetch to get in redux thunks files name

This commit is contained in:
Ismail Ali
2025-06-21 10:15:05 +02:00
parent dd76665848
commit 7740806952
42 changed files with 144 additions and 126 deletions

View File

@@ -0,0 +1,23 @@
// @/redux/thunks/getDigitalInputsThunk.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 getDigitalInputsThunk = 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);
}
}
);