From f685f4acfaba6598b8157d9de7360cd18b32828b Mon Sep 17 00:00:00 2001 From: Ismail Ali Date: Mon, 28 Apr 2025 21:44:10 +0200 Subject: [PATCH] chore: Entfernen der veralteten WindowVariablesInitializer-Komponente MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Alte Initialisierung von window-basierten Variablen entfernt - Script-Loading über DOM-Elemente wird nicht mehr benötigt - Umstellung auf saubere Datenverwaltung über Services und Redux abgeschlossen - Projektstruktur weiter aufgeräumt --- components/WindowVariablesInitializer.tsx | 60 ----------------------- config/webVersion.ts | 2 +- 2 files changed, 1 insertion(+), 61 deletions(-) delete mode 100644 components/WindowVariablesInitializer.tsx diff --git a/components/WindowVariablesInitializer.tsx b/components/WindowVariablesInitializer.tsx deleted file mode 100644 index 6f3ca59..0000000 --- a/components/WindowVariablesInitializer.tsx +++ /dev/null @@ -1,60 +0,0 @@ -// components/WindowVariables/WindowVariablesInitializer.tsx -"use client"; - -import { useEffect } from "react"; -import { useDispatch } from "react-redux"; -import { setInputs } from "../redux/slices/digitalInputsSlice"; - -const WindowVariablesInitializer = () => { - const dispatch = useDispatch(); - - useEffect(() => { - const loadScriptsAndInitialize = async () => { - try { - const isDevelopment = window.location.hostname === "localhost"; - const scriptPath = isDevelopment - ? "/CPLmockData/SERVICE/de.js" - : "/CPL/SERVICE/de.js"; - - await loadScript(scriptPath); - - const winDeState = window.win_de_state || []; - const winDeLabel = window.win_de_label || []; - - const initialInputs = winDeState.map( - (status: number, index: number) => ({ - id: index + 1, - label: winDeLabel[index] || `Eingang ${index + 1}`, - status: status === 1, - }) - ); - - dispatch(setInputs(initialInputs)); - } catch (error) { - console.error( - "Fehler beim Laden der Skripte oder Initialisieren der Inputs:", - error - ); - } - }; - - loadScriptsAndInitialize(); - }, [dispatch]); - - return null; -}; - -export default WindowVariablesInitializer; - -// Hilfsfunktion zum Laden eines Skripts -const loadScript = (src: string): Promise => { - return new Promise((resolve, reject) => { - const script = document.createElement("script"); - script.src = src; - script.async = true; - script.onload = () => resolve(); - script.onerror = () => - reject(new Error(`Fehler beim Laden des Skripts: ${src}`)); - document.head.appendChild(script); - }); -}; diff --git a/config/webVersion.ts b/config/webVersion.ts index 2778ae1..58a8fb7 100644 --- a/config/webVersion.ts +++ b/config/webVersion.ts @@ -6,5 +6,5 @@ 2: Patch oder Hotfix (Bugfixes oder kleine Änderungen). */ -const webVersion = "1.6.295"; +const webVersion = "1.6.296"; export default webVersion;