- Alle fetch-Services (TDM, TDR, analoge/digitale Eingänge/Ausgänge, SystemSettings usw.) angepasst, um `NEXT_PUBLIC_NODE_ENV` zu verwenden. - Entwicklungsumgebung lädt Daten aus /CPLmockData/... - Produktionsumgebung verwendet echte Endpunkte mit /CPL?/CPL/... - .env.production und .env.development korrekt berücksichtigt - loadWindowVariables, WindowVariablesInitializer und verwandte Dateien bereinigt - Mockdaten erscheinen nicht mehr versehentlich in Produktionsumgebung
34 lines
806 B
TypeScript
34 lines
806 B
TypeScript
// /services/fetchAllTDRReferenceChartData.ts
|
|
|
|
const getTDRReferenceBasePath = () => {
|
|
if (typeof window !== "undefined") {
|
|
const env = process.env.NEXT_PUBLIC_NODE_ENV;
|
|
return env === "development"
|
|
? "/CPLMockData/tdr-reference-curves"
|
|
: "/CPL?/CPL/tdr-reference-curves";
|
|
}
|
|
return "";
|
|
};
|
|
|
|
export const fetchAllTDRReferenceChartData = async () => {
|
|
const maxSlots = 32;
|
|
const results = [];
|
|
const basePath = getTDRReferenceBasePath();
|
|
|
|
for (let i = 0; i < maxSlots; i++) {
|
|
try {
|
|
const response = await fetch(`${basePath}/slot${i}.json`);
|
|
if (!response.ok) {
|
|
results[i] = null;
|
|
continue;
|
|
}
|
|
const json = await response.json();
|
|
results[i] = json;
|
|
} catch (error) {
|
|
results[i] = null;
|
|
}
|
|
}
|
|
|
|
return results;
|
|
};
|