From 819fde96052effead936c5f70bbf33c817077ba9 Mon Sep 17 00:00:00 2001 From: ISA Date: Wed, 20 Aug 2025 14:03:38 +0200 Subject: [PATCH] Safeguard: prevent errors when GisStationsMeasurements is empty or missing - Ensure createAndSetDevices.js always uses an array for measurements - Prevents crashes if measurement data is empty --- .env.development | 2 +- .env.production | 2 +- package-lock.json | 4 ++-- package.json | 2 +- utils/devices/createAndSetDevices.js | 8 +++++--- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.env.development b/.env.development index 623e88fee..42643a969 100644 --- a/.env.development +++ b/.env.development @@ -24,4 +24,4 @@ NEXT_PUBLIC_USE_MOCKS=true # z.B. http://10.10.0.13/xyz/index.aspx -> basePath in config.json auf /xyz setzen # basePath wird jetzt in public/config.json gepflegt # App-Versionsnummer -NEXT_PUBLIC_APP_VERSION=1.1.325 +NEXT_PUBLIC_APP_VERSION=1.1.326 diff --git a/.env.production b/.env.production index ae21f0f8e..7e4d4b56a 100644 --- a/.env.production +++ b/.env.production @@ -25,4 +25,4 @@ NEXT_PUBLIC_USE_MOCKS=false # basePath wird jetzt in public/config.json gepflegt # App-Versionsnummer -NEXT_PUBLIC_APP_VERSION=1.1.325 +NEXT_PUBLIC_APP_VERSION=1.1.326 diff --git a/package-lock.json b/package-lock.json index 8e4cb7f2e..eaf52ed78 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "nodemap", - "version": "1.1.325", + "version": "1.1.326", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "nodemap", - "version": "1.1.325", + "version": "1.1.326", "dependencies": { "@emotion/react": "^11.13.3", "@emotion/styled": "^11.13.0", diff --git a/package.json b/package.json index 685e93e06..4da835559 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodemap", - "version": "1.1.325", + "version": "1.1.326", "dependencies": { "@emotion/react": "^11.13.3", "@emotion/styled": "^11.13.0", diff --git a/utils/devices/createAndSetDevices.js b/utils/devices/createAndSetDevices.js index 23bc9bfee..1e820ba9f 100644 --- a/utils/devices/createAndSetDevices.js +++ b/utils/devices/createAndSetDevices.js @@ -49,13 +49,15 @@ export const createAndSetDevices = async ( const staticDistrictData = selectGisStationsStaticDistrict(state); const statusDistrictData = selectGisStationsStatusDistrict(state); const measurementData = selectGisStationsMeasurements(state); + // Sicherstellen, dass measurementData immer ein Array ist + const safeMeasurementData = Array.isArray(measurementData) ? measurementData : []; if (!staticDistrictData?.Points?.length) return; const hasStatus = Array.isArray(statusDistrictData) && statusDistrictData.length > 0; const statisMap = new Map(statusDistrictData.map(s => [s.IdLD, s])); const measurementsMap = new Map(); - measurementData?.forEach(m => { + safeMeasurementData.forEach(m => { if (!measurementsMap.has(m.IdLD)) { measurementsMap.set(m.IdLD, m); } @@ -118,10 +120,10 @@ export const createAndSetDevices = async ( marker.bindPopup(popupContent); // ✅ Tooltip (nur für System 11) + if (station.System === 11 && messung) { const gmaMap = new Map(); - - measurementData?.forEach(m => { + safeMeasurementData.forEach(m => { if (!gmaMap.has(m.IdLD)) { gmaMap.set(m.IdLD, {}); }