// /redux/thunks/fetchTDMDataBySlotThunk.ts

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

export const fetchTDMDataBySlotThunk = createAsyncThunk(
  "tdmSingleChart/fetchSlotData",
  async (slot: number) => {
    const data = await fetchSingleTDMDataService(slot);
    if (!data) throw new Error("Keine TDM-Daten für diesen Slot gefunden");

    return { slot, data }; // ✅ das erwartet der Slice!
  }
);
