Files
nodeMap/services/webservice/fetchGisSystemStaticService.js
ISA 3896381a8f Debug-Logging zentralisiert: Nutzung von process.env.NEXT_PUBLIC_DEBUG_LOG entfernt und auf getDebugLog() mit config.json umgestellt
- Alle Vorkommen von process.env.NEXT_PUBLIC_DEBUG_LOG entfernt
- Debug-Konfiguration erfolgt jetzt ausschließlich über public/config.json
- getDebugLog()-Utility überall verwendet
- .env-Dateien werden für Debug-Logging nicht mehr benötigt
- Alle betroffenen Komponenten, Services und API
2025-08-22 11:10:40 +02:00

61 lines
2.0 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Holt GIS-Systemdaten (Systemübersicht) vom TALAS WebService oder aus Mocks.
*
* @returns {Promise<Array>} Liste mit Systems[]
* @throws {Error} bei Fehler oder ungültiger Antwortstruktur
*/
import { getDebugLog, getConfig } from "../../utils/configUtils";
export const fetchGisSystemStaticService = async () => {
const useMocks = process.env.NEXT_PUBLIC_USE_MOCKS === "true";
const config = await getConfig();
const basePath = config.basePath || "";
if (useMocks) {
const mockBasePath = "/api/mocks/webservice/gisSystemStatic";
const mockURL = `${window.location.origin}${mockBasePath}`;
if (getDebugLog()) {
console.log("🧪 Mock-Modus aktiviert: fetchGisSystemStaticService ", mockURL);
}
const response = await fetch("/api/mocks/webservice/gisSystemStatic ");
if (!response.ok) {
throw new Error("Mockdaten konnten nicht geladen werden");
}
const mockData = await response.json();
if (!Array.isArray(mockData.Systems)) {
throw new Error("Ungültige Struktur: 'Systems' fehlt im Mock");
}
return mockData.Systems;
} else {
const baseUrl = `${window.location.protocol}//${window.location.hostname}:80${basePath}/ClientData/WebServiceMap.asmx`;
const params = new URLSearchParams(window.location.search);
const idMap = params.get("m");
const idUser = params.get("u");
const url = `${baseUrl}/GisSystemStatic?idMap=${idMap}&idUser=${idUser}`;
if (getDebugLog()) {
console.log("📡 fetchGisSystemStaticService von service URL:", url);
}
const response = await fetch(url);
if (!response.ok) {
const message = `❌ Fehler: ${response.status} ${response.statusText}`;
console.error(message);
throw new Error(message);
}
const jsonResponse = await response.json();
if (!Array.isArray(jsonResponse?.Systems)) {
throw new Error("Antwortstruktur ungültig 'Systems' fehlt oder ist kein Array");
}
return jsonResponse.Systems;
}
};