import * as config from "../../config/config"; export const fetchUserRights = async () => { let userRightsRequestCount = localStorage.getItem("userRightsRequestCount") || 0; userRightsRequestCount++; localStorage.setItem("userRightsRequestCount", userRightsRequestCount); console.log(`fetchUserRights wurde ${userRightsRequestCount} Mal aufgerufen.`); try { const response = await fetch(`${process.env.NEXT_PUBLIC_SERVER_URL}/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 []; } };