diff --git a/.env.development b/.env.development index 7b36366..419aa53 100644 --- a/.env.development +++ b/.env.development @@ -6,6 +6,6 @@ NEXT_PUBLIC_USE_MOCK_BACKEND_LOOP_START=false NEXT_PUBLIC_EXPORT_STATIC=false NEXT_PUBLIC_USE_CGI=false # App-Versionsnummer -NEXT_PUBLIC_APP_VERSION=1.6.520 +NEXT_PUBLIC_APP_VERSION=1.6.521 NEXT_PUBLIC_CPL_MODE=json # json (Entwicklungsumgebung) oder jsSimulatedProd (CPL ->CGI-Interface-Simulator) oder production (CPL-> CGI-Interface Platzhalter) diff --git a/.env.production b/.env.production index 8687609..30474a1 100644 --- a/.env.production +++ b/.env.production @@ -5,5 +5,5 @@ NEXT_PUBLIC_CPL_API_PATH=/CPL NEXT_PUBLIC_EXPORT_STATIC=true NEXT_PUBLIC_USE_CGI=true # App-Versionsnummer -NEXT_PUBLIC_APP_VERSION=1.6.520 +NEXT_PUBLIC_APP_VERSION=1.6.521 NEXT_PUBLIC_CPL_MODE=production \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 1038146..8593648 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## [1.6.521] – 2025-07-02 + +- refactor: Admin-Status direkt aus Redux ausgelesen und Props entfernt + +- isAdminLoggedIn wird jetzt direkt aus authSlice im Redux-Store gelesen +- useAdminAuth und Prop-Weitergabe entfernt +- Flackern des Firmware-Buttons dauerhaft behoben +- Codestruktur vereinfacht und stabilisiert + +--- ## [1.6.520] – 2025-07-02 - refactor: Admin-Status direkt aus Redux ausgelesen und Props entfernt diff --git a/package-lock.json b/package-lock.json index f2ac301..05390eb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cpl-v4", - "version": "1.6.520", + "version": "1.6.521", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "cpl-v4", - "version": "1.6.520", + "version": "1.6.521", "dependencies": { "@fontsource/roboto": "^5.1.0", "@iconify-icons/ri": "^1.2.10", diff --git a/package.json b/package.json index 0bbd620..3f7533e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cpl-v4", - "version": "1.6.520", + "version": "1.6.521", "private": true, "scripts": { "dev": "next dev", diff --git a/pages/_app.tsx b/pages/_app.tsx index 675abcf..1b794df 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -23,6 +23,7 @@ import { getReferenceCurveBySlotThunk } from "@/redux/thunks/getReferenceCurveBy import { getAllTDRReferenceChartThunk } from "@/redux/thunks/getAllTDRReferenceChartThunk"; import { getTDRChartDataByIdThunk } from "@/redux/thunks/getTDRChartDataByIdThunk"; import { getLoopChartDataThunk } from "@/redux/thunks/getLoopChartDataThunk"; +import { getAuthThunks } from "@/redux/thunks/getAuthThunks"; import Modal from "react-modal"; if (typeof window !== "undefined") { Modal.setAppElement("#__next"); // oder "#root", je nach App-Struktur @@ -54,6 +55,7 @@ function AppContent({ const pathname = window.location.pathname; const loadAndDispatch = () => { + dispatch(getAuthThunks()); if (pathname.includes("kabelueberwachung")) { dispatch(getKueDataThunk()); } else if (pathname.includes("digitalOutputs")) { diff --git a/redux/thunks/getAuthThunks.ts b/redux/thunks/getAuthThunks.ts new file mode 100644 index 0000000..c25415b --- /dev/null +++ b/redux/thunks/getAuthThunks.ts @@ -0,0 +1,12 @@ +// redux/thunks/getAuthThunks.ts +import { createAsyncThunk } from "@reduxjs/toolkit"; +import { fetchAuthService } from "@/services/fetchAuthService"; +import { setAdminLoggedIn } from "@/redux/slices/authSlice"; + +export const getAuthThunks = createAsyncThunk( + "auth/getAuthThunks", + async (_, { dispatch }) => { + const { isAdminLoggedIn } = fetchAuthService(); + dispatch(setAdminLoggedIn(isAdminLoggedIn)); // boolean, nicht string! + } +); diff --git a/services/fetchAuthService.ts b/services/fetchAuthService.ts new file mode 100644 index 0000000..0a835a2 --- /dev/null +++ b/services/fetchAuthService.ts @@ -0,0 +1,6 @@ +// services/fetchAuthService.ts +export const fetchAuthService = () => { + const isAdminLoggedInRaw = localStorage.getItem("isAdminLoggedIn"); + const isAdminLoggedIn = isAdminLoggedInRaw === "true"; // <– explizit Boolean + return { isAdminLoggedIn }; +};