From 1bf3253128903e2d67a2b9afc0cfd507b31855a6 Mon Sep 17 00:00:00 2001 From: Barni Date: Mon, 20 Oct 2025 17:14:37 +0200 Subject: [PATCH] Lobby --- SerpentRace_Frontend/src/App.jsx | 2 + .../src/components/Landingpage/PlayMenu.jsx | 1 - .../src/pages/Lobby/Lobby.jsx | 96 +++++++++++++++++++ 3 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 SerpentRace_Frontend/src/pages/Lobby/Lobby.jsx diff --git a/SerpentRace_Frontend/src/App.jsx b/SerpentRace_Frontend/src/App.jsx index 5831b3a7..0314253e 100644 --- a/SerpentRace_Frontend/src/App.jsx +++ b/SerpentRace_Frontend/src/App.jsx @@ -15,6 +15,7 @@ import About from "./pages/About/About" import ScrollToTop from "./components/ScrollToTop" import GameScreen from "./pages/Game/GameScreen" import Reports from "./pages/Report/Reports" +import Lobby from "./pages/Lobby/Lobby" function App() { const [isMobile, setIsMobile] = useState(false) @@ -46,6 +47,7 @@ function App() { } /> + } /> } /> } /> } /> diff --git a/SerpentRace_Frontend/src/components/Landingpage/PlayMenu.jsx b/SerpentRace_Frontend/src/components/Landingpage/PlayMenu.jsx index afa9473f..d055a31b 100644 --- a/SerpentRace_Frontend/src/components/Landingpage/PlayMenu.jsx +++ b/SerpentRace_Frontend/src/components/Landingpage/PlayMenu.jsx @@ -85,7 +85,6 @@ const PlayMenu = ({ onJoinGame, onCreateGame, user }) => {
Nincs bejelentkezve
)} - {/* opcionális kis info ikon helye, ha később kell */}
diff --git a/SerpentRace_Frontend/src/pages/Lobby/Lobby.jsx b/SerpentRace_Frontend/src/pages/Lobby/Lobby.jsx new file mode 100644 index 00000000..00760124 --- /dev/null +++ b/SerpentRace_Frontend/src/pages/Lobby/Lobby.jsx @@ -0,0 +1,96 @@ +import React, { useEffect, useRef, useState } from "react" +import { useNavigate, useLocation } from "react-router-dom" +import Navbar from "../../components/Navbar/Navbar" +import Background from "../../assets/backgrounds/Background.jsx" +import useRequireAuth from "../../hooks/useRequireAuth" + +const Lobby = () => { + const [visible, setVisible] = useState(false) + const sectionRef = useRef(null) + const navigate = useNavigate() + const location = useLocation() + + + const [user, setUser] = useRequireAuth() + + useEffect(() => { + const observer = new IntersectionObserver( + ([entry]) => { + if (entry.isIntersecting) setVisible(true) + }, + { threshold: 0.3 } + ) + if (sectionRef.current) observer.observe(sectionRef.current) + return () => observer.disconnect() + }, []) + + const handleExit = () => { + if (window.confirm("Biztosan ki szeretnél lépni a lobbyból?")) { + navigate("/home") + } + } + + const getInitials = (name) => { + return name + .split(" ") + .map((n) => n[0]) + .join("") + .slice(0, 2) + .toUpperCase() + } + + return ( +
+
+ +
+ +
+ +
+ +
+
+

+ {user} Lobby-ja +

+ +

+ Játékosok, akik csatlakoztak ehhez a szobához: +

+ +
+
    +
  • +
    + {getInitials(user)} +
    + {user} +
  • +
+
+ +
+ +
+
+
+
+ ) +} + +export default Lobby