diff --git a/components/main/kabelueberwachung/kue705FO/modals/KueEinstellung.tsx b/components/main/kabelueberwachung/kue705FO/modals/KueEinstellung.tsx index ee00036..542cd41 100644 --- a/components/main/kabelueberwachung/kue705FO/modals/KueEinstellung.tsx +++ b/components/main/kabelueberwachung/kue705FO/modals/KueEinstellung.tsx @@ -1,9 +1,11 @@ -"use client"; // KueEinstellung.tsx – komplett angepasst mit window.__kueCache zum Schutz vor Remount-Reset +// KueEinstellung.tsx – vollständige Version mit handleSave eingebunden -import { useEffect, useState } from "react"; -import { useDispatch, useSelector } from "react-redux"; +"use client"; + +import { useState } from "react"; +import { useSelector, useDispatch } from "react-redux"; import type { RootState } from "../../../../../redux/store"; -import { setKueData } from "../../../../../redux/slices/kueDataSlice"; +import handleSave from "../handlers/handleSave"; import handleDisplayEinschalten from "../handlers/handleDisplayEinschalten"; import firmwareUpdate from "../handlers/firmwareUpdate"; import { useAdminAuth } from "../../../settingsPageComponents/hooks/useAdminAuth"; @@ -31,8 +33,8 @@ export default function KueEinstellung({ slot, showModal, onClose = () => {}, + onModulNameChange, }: Props) { - const dispatch = useDispatch(); const { kueID, kueLimit1, @@ -43,12 +45,12 @@ export default function KueEinstellung({ } = useSelector((state: RootState) => state.kueDataSlice); const { isAdminLoggedIn } = useAdminAuth(true); + const dispatch = useDispatch(); const formCacheKey = `slot_${slot}`; if (typeof window !== "undefined") { window.__kueCache = window.__kueCache || {}; } - const cached = typeof window !== "undefined" ? window.__kueCache?.[formCacheKey] : null; @@ -68,7 +70,7 @@ export default function KueEinstellung({ const updated = { ...formData, [key]: value }; setFormData(updated); if (typeof window !== "undefined") { - window.__kueCache[formCacheKey] = updated; + window.__kueCache![formCacheKey] = updated; } }; @@ -91,22 +93,32 @@ export default function KueEinstellung({ const updatedMemoryInterval = [...memoryInterval]; updatedMemoryInterval[slot] = Number(formData.memoryInterval); - dispatch( - setKueData({ - kueID: updatedKueID, - kueLimit1: updatedLimit1, - kueDelay1: updatedDelay1, - kueLimit2Low: updatedLimit2Low, - kueLoopInterval: updatedLoopInterval, - memoryInterval: updatedMemoryInterval, - }) - ); + handleSave({ + ids: updatedKueID, + isolationsgrenzwerte: updatedLimit1, + verzoegerung: updatedDelay1, + untereSchleifenGrenzwerte: updatedLimit2Low, + obereSchleifenGrenzwerte: updatedLimit2Low, + schleifenintervall: updatedLoopInterval, + speicherintervall: updatedMemoryInterval, + originalValues: { + kueID, + isolationsgrenzwerte: kueLimit1, + verzoegerung: kueDelay1, + untereSchleifenGrenzwerte: kueLimit2Low, + obereSchleifenGrenzwerte: kueLimit2Low, + schleifenintervall: kueLoopInterval, + speicherintervall: memoryInterval, + }, + slot, + dispatch, // du kannst dispatch hier übergeben, falls nötig + onModulNameChange: onModulNameChange ?? (() => {}), + onClose, + }); if (typeof window !== "undefined") { - delete window.__kueCache[formCacheKey]; + delete window.__kueCache?.[formCacheKey]; } - - onClose(); }; return ( diff --git a/config/webVersion.ts b/config/webVersion.ts index 69daf9c..03e01ee 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.316"; +const webVersion = "1.6.317"; export default webVersion; diff --git a/tsconfig.json b/tsconfig.json index 74c61ea..92ed192 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,24 +11,11 @@ "allowSyntheticDefaultImports": true, "noEmit": true, "skipLibCheck": true, - "types": [ - "cypress", - "node" - ], - "lib": [ - "dom", - "dom.iterable", - "esnext" - ], + "types": ["cypress", "node"], + "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "incremental": true }, - "include": [ - "src", - "**/*.test.ts", - "**/*.test.tsx" - ], - "exclude": [ - "node_modules" - ] + "include": ["src", "**/*.test.ts", "**/*.test.tsx", "types/global.d.ts"], + "exclude": ["node_modules"] } diff --git a/types/global.d.ts b/types/global.d.ts new file mode 100644 index 0000000..426f037 --- /dev/null +++ b/types/global.d.ts @@ -0,0 +1,9 @@ +// types/global.d.ts +export {}; + +declare global { + interface Window { + __kueCache?: Record; + kabelModalOpen?: boolean; // ✅ HIER NEU + } +}