diff --git a/app/kabelueberwachung/page.jsx b/app/kabelueberwachung/page.jsx index feda410..7a60e12 100644 --- a/app/kabelueberwachung/page.jsx +++ b/app/kabelueberwachung/page.jsx @@ -2,6 +2,7 @@ import React, { useState, useEffect } from "react"; import { useRouter } from "next/navigation"; import Kue705FO from "../../components/modules/Kue705FO"; +import { loadWindowVariables } from "../../utils/loadWindowVariables"; function Kabelueberwachung() { const router = useRouter(); @@ -23,20 +24,24 @@ function Kabelueberwachung() { // Load the external JavaScript file and fetch the isolation values useEffect(() => { - if (window.kueIso && Array.isArray(window.kueIso)) { - setKueIso(window.kueIso); // Store the isolation values from the global variable - } - - if (window.kueRes && Array.isArray(window.kueRes)) { - setSchleifenwiderstand(window.kueRes); // Store the resistance values from the global variable - } - - if (window.kueOnline && Array.isArray(window.kueOnline)) { - setKueOnline(window.kueOnline); // Store the module status from the global variable - } - if (window.kueID && Array.isArray(window.kueID)) { - setKueID(window.kueID); // Store the KUE names from the global variable - } + loadWindowVariables() + .then(() => { + if (window.kueIso && Array.isArray(window.kueIso)) { + setKueIso(window.kueIso); + } + if (window.kueRes && Array.isArray(window.kueRes)) { + setSchleifenwiderstand(window.kueRes); + } + if (window.kueOnline && Array.isArray(window.kueOnline)) { + setKueOnline(window.kueOnline); + } + if (window.kueID && Array.isArray(window.kueID)) { + setKueID(window.kueID); + } + }) + .catch((error) => { + console.error("Fehler beim Laden der Variablen:", error); + }); }, []); // Zuerst alle Werte der Arrays speichern