From 40838b04ab1608c2f7f800c2c82fc3eef287d9dd Mon Sep 17 00:00:00 2001 From: sina_sajjadi Date: Sat, 16 May 2026 12:01:47 +0330 Subject: [PATCH] refactor: remove GlobalAuthDebugOverlay component to streamline layout --- src/app/layout.tsx | 2 - .../dev/global-auth-debug-overlay.tsx | 71 ------------------- 2 files changed, 73 deletions(-) delete mode 100644 src/components/dev/global-auth-debug-overlay.tsx diff --git a/src/app/layout.tsx b/src/app/layout.tsx index f4c10c0..278017b 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -4,7 +4,6 @@ import localFont from "next/font/local"; import Providers from "./providers"; import "./globals.css"; import DevClickToComponent from "@/components/dev/dev-click-to-component"; -import GlobalAuthDebugOverlay from "@/components/dev/global-auth-debug-overlay"; const faminela = localFont({ src: "../../public/fonts/Faminela/Faminela.otf", @@ -148,7 +147,6 @@ export default function RootLayout({
{children}
-
{process.env.NODE_ENV === "development" ? ( diff --git a/src/components/dev/global-auth-debug-overlay.tsx b/src/components/dev/global-auth-debug-overlay.tsx deleted file mode 100644 index 0ec716d..0000000 --- a/src/components/dev/global-auth-debug-overlay.tsx +++ /dev/null @@ -1,71 +0,0 @@ -"use client"; - -import { useEffect, useState } from "react"; -import { authBridge } from "@/lib/auth-bridge"; - -const TEST_SESSION_KEY = "TEST_DEBUG_NOT_LOGGED_IN"; -const TEST_SESSION_VALUE = "true"; - -function ensureTestSessionKey(isAuthenticated: boolean) { - if (typeof window === "undefined") { - return false; - } - - const existingValue = window.sessionStorage.getItem(TEST_SESSION_KEY); - - // Test-only behavior: create the key once for logged-out users and then - // never overwrite or remove it, even after login. - if (existingValue === null && !isAuthenticated) { - window.sessionStorage.setItem(TEST_SESSION_KEY, TEST_SESSION_VALUE); - return true; - } - - return existingValue !== null; -} - -function readOverlayState() { - if (typeof window === "undefined") { - return { - hasKey: false, - isAuthenticated: false, - }; - } - - const isAuthenticated = authBridge.isAuthenticated(); - - return { - hasKey: ensureTestSessionKey(isAuthenticated), - isAuthenticated, - }; -} - -export default function GlobalAuthDebugOverlay() { - const [overlayState, setOverlayState] = useState(readOverlayState); - - useEffect(() => { - const syncOverlayState = () => { - setOverlayState(readOverlayState()); - }; - - syncOverlayState(); - - window.addEventListener("focus", syncOverlayState); - const intervalId = window.setInterval(syncOverlayState, 1000); - - return () => { - window.removeEventListener("focus", syncOverlayState); - window.clearInterval(intervalId); - }; - }, []); - - return ( -
-
-
auth: {overlayState.isAuthenticated ? "logged-in" : "logged-out"}
-
- {TEST_SESSION_KEY}: {overlayState.hasKey ? "exists" : "missing"} -
-
-
- ); -}