diff --git a/client/src/components/common/Navbar.jsx b/client/src/components/common/Navbar.jsx
index 915a1f2..3a0feb2 100644
--- a/client/src/components/common/Navbar.jsx
+++ b/client/src/components/common/Navbar.jsx
@@ -1,4 +1,4 @@
-import { useState } from "react";
+import { useState, useEffect } from "react";
import { useNavigate } from "react-router-dom";
import { Menu, X } from "lucide-react"; // hamburger + close icons
import avatar from "/avatars/1.png";
@@ -6,6 +6,7 @@ import avatar from "/avatars/1.png";
export default function Navbar() {
const navigate = useNavigate();
const [menuOpen, setMenuOpen] = useState(false);
+ const [isLoggedIn, setIsLoggedIn] = useState(false);
const navItems = [
{ label: "Home", path: "/landing" },
@@ -14,6 +15,23 @@ export default function Navbar() {
{ label: "How to Play", path: "/how-to-play" },
];
+ useEffect(() => {
+ const token = localStorage.getItem("token");
+ setIsLoggedIn(!!token);
+ }, []);
+
+ const handleAuthAction = () => {
+ if (isLoggedIn) {
+ localStorage.removeItem("token");
+ localStorage.removeItem("user");
+ setIsLoggedIn(false);
+ navigate("/login");
+ } else {
+ navigate("/login");
+ }
+ setMenuOpen(false); // close mobile menu if open
+ };
+
return (
);
diff --git a/client/src/pages/HomePage.jsx b/client/src/pages/HomePage.jsx
index 2782330..feb924b 100644
--- a/client/src/pages/HomePage.jsx
+++ b/client/src/pages/HomePage.jsx
@@ -10,6 +10,13 @@ import {
const HomePage = () => {
const navigate = useNavigate();
+ // ✅ Redirect if already logged in
+ useEffect(() => {
+ const token = localStorage.getItem("token");
+ if (token) {
+ navigate("/landing", { replace: true });
+ }
+ }, [navigate]);
const blobRef = useRef(null);
const [mousePosition, setMousePosition] = useState({
x: window.innerWidth / 2,
diff --git a/client/src/pages/LandingPage.jsx b/client/src/pages/LandingPage.jsx
index be42b8e..3e56df2 100644
--- a/client/src/pages/LandingPage.jsx
+++ b/client/src/pages/LandingPage.jsx
@@ -34,59 +34,59 @@ export default function LandingPage() {
};
return (
-
+
{/* Scale landing body */}
-
-
+
+
{/* Greeting */}
Hello{greeted ? `, ${name}!` : "!"}
{/* Mobile Input & Button separated */}
-
-
+
{/* Desktop Input + Button inside border */}
-
+
setName(e.target.value)}
disabled={isSignedUp}
- className="px-4 py-3 w-full text-base border-2 border-black rounded-[6px] text-black placeholder-black font-silkscreen bg-white outline-black disabled:opacity-50 disabled:cursor-not-allowed"
+ className="px-4 py-3 w-full text-base border-2 border-black rounded-md text-black placeholder-black font-silkscreen bg-white outline-black disabled:opacity-50 disabled:cursor-not-allowed"
/>
{/* Avatar Selector */}
-
+
{
@@ -98,7 +98,7 @@ export default function LandingPage() {
{/* Join/Create Buttons */}
-
+
Have A Room-Code?
@@ -106,7 +106,7 @@ export default function LandingPage() {
navigate("/join-room")}
disabled={!name.trim() || !avatar}
/>
@@ -118,7 +118,7 @@ export default function LandingPage() {
navigate("/create-room")}
disabled={!name.trim() || !avatar}
/>