27 lines
919 B
JavaScript
27 lines
919 B
JavaScript
// /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
|
|
}
|
|
|
|
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 [];
|
|
}
|
|
};
|