refactor: TDR-Daten in neuen tdrSingleChartSlice ausgelagert und nur pro Slot geladen
- Globalen fetchAllTDRChartData entfernt - Neuen Slice und Thunk pro Slot erstellt - TDRChart liest initiale Daten aus neuem Slice
This commit is contained in:
20
services/fetchSingleTDRChartData.ts
Normal file
20
services/fetchSingleTDRChartData.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
// /services/fetchSingleTDRChartData.ts
|
||||
|
||||
export const fetchTDRChartDataBySlot = async (
|
||||
slot: number
|
||||
): Promise<any[] | null> => {
|
||||
const isDev = process.env.NEXT_PUBLIC_NODE_ENV === "development";
|
||||
|
||||
const url = isDev
|
||||
? `/CPLmockData/LastTDR/jsonDatei/slot${slot}.json`
|
||||
: `${window.location.origin}/CPL?/CPL/LastTDR/slot${slot}.json`;
|
||||
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
console.error(`❌ Fehler beim Laden von slot${slot}:`, error);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user