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,14 +1,21 @@
|
||||
// /services/webservice/fetchGisStationsMeasurementsService.js
|
||||
|
||||
export const fetchGisStationsMeasurementsService = 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: fetchGisStationsMeasurementsService");
|
||||
const { mockGisStationsMeasurements } = await import("../../__mocks__/webservice/gisStationsMeasurements.js");
|
||||
return mockGisStationsMeasurements.Statis;
|
||||
|
||||
const response = await fetch("/mocks/webservice/gisStationsMeasurements.json");
|
||||
if (!response.ok) {
|
||||
throw new Error("Mockdaten konnten nicht geladen werden");
|
||||
}
|
||||
|
||||
const mockData = await response.json();
|
||||
if (!Array.isArray(mockData.Statis)) {
|
||||
throw new Error("Ungültige Struktur: 'Statis' fehlt im Mock");
|
||||
}
|
||||
|
||||
return mockData.Statis;
|
||||
} else {
|
||||
const baseUrl = `${window.location.protocol}//${window.location.hostname}:80${basePath}/ClientData/WebServiceMap.asmx`;
|
||||
|
||||
@@ -36,7 +43,7 @@ export const fetchGisStationsMeasurementsService = async () => {
|
||||
throw new Error("Antwort ist kein gültiges JSON");
|
||||
}
|
||||
|
||||
if (!jsonResponse?.Statis) {
|
||||
if (!Array.isArray(jsonResponse.Statis)) {
|
||||
throw new Error("Antwortstruktur ungültig – 'Statis' fehlt");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user