- Start.js (last20Messages) als JS-Mock in /apiMockData/jsMockFiles gespeichert - de.js (digitale Eingänge) in /apiMockData/SERVICE verlagert - Beide werden über eigene API-Endpoints bzw. per Script-Tag aus Development-Verzeichnis geladen - Kein Zugriff mehr über /public notwendig, Verhalten in DEV und PROD identisch
28 lines
863 B
TypeScript
28 lines
863 B
TypeScript
// /services/fetchTDRReferenceCurve.ts
|
|
|
|
export const fetchTDRReferenceCurve = async (
|
|
slot: number
|
|
): Promise<any[] | null> => {
|
|
// ✅ Erst aus localStorage lesen
|
|
const local = localStorage.getItem(`ref-curve-slot${slot}`);
|
|
if (local) {
|
|
console.log(`📦 Lade Referenzkurve für Slot ${slot} aus localStorage`);
|
|
return JSON.parse(local);
|
|
}
|
|
|
|
// 🔁 Fallback: Datei oder Produktion-API
|
|
const isDev = process.env.NEXT_PUBLIC_NODE_ENV === "development";
|
|
const url = isDev
|
|
? `/apiMockData/tdr-reference-curves/slot${slot}.json`
|
|
: `${window.location.origin}/CPL?Service/empty.acp&TDR=${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;
|
|
}
|
|
};
|