feat: Webservice-Mockdaten im public-Verzeichnis hinzugefügt
- JSON-Dateien für Linienstatus, Stationsstatus, Systemdaten und Benutzerrechte unter /public/mocks/webservice/ abgelegt - Struktur der Dateien an echte Webservice-Antworten angepasst (z. B. 'Statis' statt 'Status') - Dienste wurden entsprechend auf Umschaltung zwischen Mock- und Echtbetrieb vorbereitet - Ermöglicht lokale Entwicklung und Tests ohne Backend-Verbindung
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
// /services/webservice/fetchGisStationsStaticDistrictService.js
|
||||
|
||||
/**
|
||||
* Holt statische GIS-Stationen-Daten für Bezirke.
|
||||
* Wechselt automatisch zwischen echten Daten und Mock-Daten via .env.local
|
||||
@@ -9,13 +7,22 @@
|
||||
*/
|
||||
export const fetchGisStationsStaticDistrictService = async () => {
|
||||
const useMocks = process.env.NEXT_PUBLIC_USE_MOCKS === "true";
|
||||
const mode = process.env.NEXT_PUBLIC_API_PORT_MODE;
|
||||
const basePath = process.env.NEXT_PUBLIC_BASE_PATH || "";
|
||||
|
||||
if (useMocks) {
|
||||
console.log("🧪 Mock-Modus aktiviert: fetchGisStationsStaticDistrictService");
|
||||
const { mockGisStationsStaticDistrict } = await import("../../__mocks__/webservice/gisStationsStaticDistrict.js");
|
||||
return mockGisStationsStaticDistrict.Points;
|
||||
|
||||
const res = await fetch("/mocks/webservice/gisStationsStaticDistrict.json");
|
||||
if (!res.ok) {
|
||||
throw new Error("Mockdaten konnten nicht geladen werden");
|
||||
}
|
||||
|
||||
const mockData = await res.json();
|
||||
if (!Array.isArray(mockData.Points)) {
|
||||
throw new Error("Mockdaten enthalten kein gültiges 'Points'-Feld");
|
||||
}
|
||||
|
||||
return mockData.Points;
|
||||
} else {
|
||||
const baseUrl = `${window.location.protocol}//${window.location.hostname}:80${basePath}/ClientData/WebServiceMap.asmx`;
|
||||
|
||||
@@ -34,7 +41,7 @@ export const fetchGisStationsStaticDistrictService = async () => {
|
||||
}
|
||||
|
||||
const jsonResponse = await response.json();
|
||||
if (!jsonResponse?.Points) {
|
||||
if (!Array.isArray(jsonResponse.Points)) {
|
||||
throw new Error("Antwortstruktur ungültig – 'Points' fehlt");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user