chore: config.js entfernt – Konfiguration zentral über .env.local

- alle Importe und Aufrufe von config.js entfernt
- Webservices nutzen direkt window.location + NEXT_PUBLIC_API_PORT_MODE
- zentrale Konfigurationsstrategie über .env.local abgeschlossen
This commit is contained in:
ISA
2025-05-22 15:02:57 +02:00
parent ef3c511694
commit b48a5b2b58
8 changed files with 44 additions and 70 deletions

View File

@@ -1,26 +1,25 @@
// /services/webservice/fetchUserRightsService.js
import * as config from "../../config/config";
export const fetchUserRightsService = async () => {
if (config.USE_MOCK_API) {
console.log("⚠️ Mock-API: Benutzerrechte geladen");
return [56, 57, 58]; // Beispielrechte
const mode = process.env.NEXT_PUBLIC_API_PORT_MODE;
const apiBaseUrl = mode === "dev" ? `${window.location.protocol}//${window.location.hostname}:80/talas5/ClientData/WebServiceMap.asmx` : `${window.location.origin}/talas5/ClientData/WebServiceMap.asmx`;
const params = new URLSearchParams(window.location.search);
const idMap = params.get("m");
const idUser = params.get("u");
const url = `${apiBaseUrl}/GetUserRights?idMap=${idMap}&idUser=${idUser}`;
const response = await fetch(url, {
method: "GET",
headers: {
Connection: "close",
},
});
if (!response.ok) {
throw new Error("Fehler beim Abrufen der Benutzerrechte");
}
try {
const response = await fetch(`${config.serverURL}/talas5/ClientData/WebserviceMap.asmx/GisSystemStatic?idMap=${config.idMap}&idUser=${config.idUser}`, {
method: "GET",
headers: { Connection: "close" },
});
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
const data = await response.json();
if (!data || !data.Rights || !Array.isArray(data.Rights)) throw new Error("Invalid response structure");
return data.Rights.map((right) => right.IdRight);
} catch (error) {
console.error("Fehler beim Abrufen der Benutzerrechte:", error);
return [];
}
const json = await response.json();
return json.Rights || [];
};