feat: Referenzkurve pro Slot dynamisch per Redux Slice laden und anzeigen

- Neuen Slice `tdrReferenceChartDataBySlot` eingeführt
- Thunk `fetchReferenceCurveBySlotThunk` erstellt
- Referenzdaten pro Slot in Redux gespeichert
- Zugriff im TDRChart angepasst auf neue Struktur
This commit is contained in:
Ismail Ali
2025-03-30 13:32:32 +02:00
parent 91cc60568a
commit cb2deecf17
6 changed files with 89 additions and 3 deletions

View File

@@ -0,0 +1,24 @@
// /services/fetchTDRReferenceCurve.ts
export const fetchTDRReferenceCurve = async (
slot: number
): Promise<any[] | null> => {
if (typeof window === "undefined") return null;
const isDev = process.env.NEXT_PUBLIC_NODE_ENV === "development";
const url = isDev
? `/CPLmockData/tdr-reference-curves/slot${slot}.json`
: `${window.location.origin}/CPL?Service/empty.acp&TDRR=${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 der Referenzkurve für Slot ${slot}:`,
error
);
return null;
}
};