diff --git a/public/images/battlesnake-neon-logo.GIF b/public/images/battlesnake-neon-logo.GIF new file mode 100644 index 0000000..1426891 Binary files /dev/null and b/public/images/battlesnake-neon-logo.GIF differ diff --git a/public/images/battlesnake-neon-logo.jpg b/public/images/battlesnake-neon-logo1.jpg similarity index 100% rename from public/images/battlesnake-neon-logo.jpg rename to public/images/battlesnake-neon-logo1.jpg diff --git a/src/components/Hero.jsx b/src/components/Hero.jsx index 10552f7..b6f7ac3 100644 --- a/src/components/Hero.jsx +++ b/src/components/Hero.jsx @@ -13,20 +13,6 @@ function Hero() { cursor.style.top = `${e.clientY}px`; } }; - async function fetchUser() { - const res = await fetch("http://localhost:3000/api/current_user", { - credentials: "include", // very important - }); - if (res.ok) { - const user = await res.json(); - console.log("User display name:", user.displayName); - - setUser(user); - } else { - setUser(null); - } - } - fetchUser(); window.addEventListener("mousemove", handleMouseMove); @@ -141,7 +127,7 @@ function Hero() {
BattleSnake Neon Logo diff --git a/src/components/Navbar.jsx b/src/components/Navbar.jsx index c7533cb..3b48d56 100644 --- a/src/components/Navbar.jsx +++ b/src/components/Navbar.jsx @@ -6,6 +6,7 @@ import { Link } from "react-router-dom"; const Navbar = () => { const [glitchEffect, setGlitchEffect] = useState(false); const [activeLink, setActiveLink] = useState("/"); + const [user, setUser] = useState(null); useEffect(() => { // Set active link based on current path @@ -16,6 +17,22 @@ const Navbar = () => { setGlitchEffect(true); setTimeout(() => setGlitchEffect(false), 200); }, 3000); + async function fetchUser() { + const res = await fetch("http://localhost:8080/auth/current_user", { + credentials: "include", // very important + }); + if (res.ok) { + console.log("User response:", res); + const user = await res.json(); + console.log("User:", user); + console.log("User display name:", user.displayName); + + setUser(user); + } else { + setUser(null); + } + } + fetchUser(); return () => clearInterval(glitchInterval); }, []); @@ -29,6 +46,13 @@ const Navbar = () => {
+ {user && ( +
+ WELCOME + {user.displayName} +
+ )} +