import { useEffect, useState, Suspense, lazy } from "react"; import { BrowserRouter, Routes, Route } from "react-router-dom"; import { TOKEN_KEY } from "./api"; const Profile = lazy(() => import("./Profile")); const HackGame = lazy(() => import("./HackGame")); const AdminDashboard = lazy(() => import("./AdminDashboard")); function AuthHandler({ children }: { children: React.ReactNode }) { const [isProcessing, setIsProcessing] = useState(true); const [isAuthenticated, setIsAuthenticated] = useState(false); useEffect(() => { const hash = window.location.hash; if (hash.includes("token=")) { const params = new URLSearchParams(hash.replace("#", "?")); const token = params.get("token"); if (token) { localStorage.setItem(TOKEN_KEY, token); window.history.replaceState(null, "", window.location.pathname); } } if (localStorage.getItem(TOKEN_KEY)) { setIsAuthenticated(true); } setIsProcessing(false); }, []); if (isProcessing) { return (