refactor: Naming-Konventionen für digitaleEingaenge umgesetzt

- digitaleEingaengeMockData.js = strukturierte Datenbasis für Development
- digitaleEingaengeAPIHandler.ts = API-Endpunkt zur Auslieferung im Dev
- fetchDigitaleEingaengeService.ts = Service zur Umwandlung von window-Variablen
- Naming-Schema sorgt für klare Struktur und gute Lernbarkeit
This commit is contained in:
Ismail Ali
2025-04-15 08:55:50 +02:00
parent fb87e7b3ae
commit f709c2e3b7
22 changed files with 22 additions and 22 deletions

View File

@@ -0,0 +1,22 @@
// /services/fetchAllTDMDataService.ts
export const fetchAllTDMDataFromServer = async (): Promise<any[]> => {
if (typeof window === "undefined") return [];
const isDev = process.env.NEXT_PUBLIC_NODE_ENV === "development";
const slotRequests = Array.from({ length: 32 }, (_, i) => {
const url = isDev
? `/apiMockData/TDM/slot${i}.json` // ✅ Entwicklung: aus public-Ordner
: `${window.location.origin}/CPL?Service/empty.acp&TDM=${i}`; // ✅ Produktion
return fetch(url)
.then((res) => (res.ok ? res.json() : null))
.catch((err) => {
console.error(`❌ Fehler bei Slot ${i}:`, err);
return null;
});
});
return await Promise.all(slotRequests);
};