36 lines
964 B
TypeScript
36 lines
964 B
TypeScript
// /redux/thunks/getSystemChartDataThunk.ts
|
|
import { createAsyncThunk } from "@reduxjs/toolkit";
|
|
import { fetchSystemChartData } from "@/services/fetchSystemChartDataService";
|
|
|
|
interface FetchSystemChartDataParams {
|
|
mode: "DIA0" | "DIA1" | "DIA2";
|
|
type: number;
|
|
slotNumber: number;
|
|
vonDatum: string;
|
|
bisDatum: string;
|
|
}
|
|
|
|
export const getSystemChartDataThunk = createAsyncThunk(
|
|
"systemChart/fetchSystemChartData",
|
|
async (params: FetchSystemChartDataParams, { rejectWithValue }) => {
|
|
try {
|
|
const data = await fetchSystemChartData(
|
|
params.mode,
|
|
params.type,
|
|
params.slotNumber,
|
|
params.vonDatum,
|
|
params.bisDatum
|
|
);
|
|
|
|
if (!data) {
|
|
return rejectWithValue("Keine Daten erhalten");
|
|
}
|
|
|
|
return data;
|
|
} catch (error: any) {
|
|
console.error("❌ Fehler in getSystemChartDataThunk:", error);
|
|
return rejectWithValue(error.message || "Unbekannter Fehler");
|
|
}
|
|
}
|
|
);
|