- Globalen fetchAllTDRChartData entfernt - Neuen Slice und Thunk pro Slot erstellt - TDRChart liest initiale Daten aus neuem Slice
21 lines
602 B
TypeScript
21 lines
602 B
TypeScript
// /services/fetchSingleTDMData.ts
|
|
|
|
export const fetchTDMDataBySlot = async (slot: number): Promise<any> => {
|
|
if (typeof window === "undefined") return null;
|
|
|
|
const isDev = process.env.NEXT_PUBLIC_NODE_ENV === "development";
|
|
|
|
const url = isDev
|
|
? `/CPLmockData/TDM/slot${slot}.json`
|
|
: `${window.location.origin}/CPL?Service/empty.acp&TDM=${slot}`;
|
|
|
|
try {
|
|
const res = await fetch(url);
|
|
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
return await res.json();
|
|
} catch (error) {
|
|
console.error(`❌ Fehler beim Laden von Slot ${slot}:`, error);
|
|
return null;
|
|
}
|
|
};
|