import { createAsyncThunk } from "@reduxjs/toolkit";
import { fetchTemperaturAdWandlerService } from "@/services/fetchTemperaturAdWandlerService";

export const getTemperaturAdWandlerThunk = createAsyncThunk(
  "temperaturAdWandler/fetch",
  async (typ: "DIA0" | "DIA1" | "DIA2", thunkAPI) => {
    try {
      const data = await fetchTemperaturAdWandlerService(typ);
      return { typ, data };
    } catch (error) {
      console.error("Fehler in getTemperaturAdWandlerThunk:", error);
      return thunkAPI.rejectWithValue("Fehler beim Laden der Temperaturdaten");
    }
  }
);
