From 2707efe115c622effa0e5d3ac831f9345018ae67 Mon Sep 17 00:00:00 2001 From: Michess Date: Wed, 15 Apr 2026 13:14:15 +0200 Subject: [PATCH] feat(ui): move admin panel and join-game into profile dropdown - Replace header admin link + profile modal with a dropdown menu - Dropdown contains: profile, settings, admin (admins only), join-game form, logout - Remove join-game card from homepage for logged-in users (now in dropdown) - AuthModal now only handles guest/login/register flows Co-Authored-By: Claude Sonnet 4.6 --- client/src/app/page.tsx | 17 +-- client/src/components/Header.tsx | 71 ++++++++-- client/src/components/auth/AuthModal.tsx | 160 ++++++++--------------- 3 files changed, 117 insertions(+), 131 deletions(-) diff --git a/client/src/app/page.tsx b/client/src/app/page.tsx index f78ea8e..d74b5c3 100644 --- a/client/src/app/page.tsx +++ b/client/src/app/page.tsx @@ -82,21 +82,8 @@ export default function Home() { {/* Laufende Partien – Live-Kacheln */} - {/* Öffentliche Spiele + Beitreten */} -
-
- -
- {isLoggedIn && ( -
-
-

🔗 Einladung annehmen

-

Link oder Code eingeben

- -
-
- )} -
+ {/* Öffentliche Spiele */} + ); diff --git a/client/src/components/Header.tsx b/client/src/components/Header.tsx index 4dabb5e..b26338e 100644 --- a/client/src/components/Header.tsx +++ b/client/src/components/Header.tsx @@ -1,13 +1,20 @@ "use client"; -import { IconUser, IconShield } from "@tabler/icons-react"; +import { IconUser, IconShield, IconUserCircle, IconSettings2, IconLogout } from "@tabler/icons-react"; import Link from "next/link"; import NotificationPanel from "./NotificationPanel"; import ThemeToggle from "./ThemeToggle"; import { useSession } from "@/context/session"; +import { logout } from "@/lib/auth"; +import JoinGame from "./home/JoinGame"; export default function Header() { - const { user } = useSession(); + const { user, setUser } = useSession(); + + async function handleLogout() { + await logout(); + setUser(null); + } return (
@@ -30,12 +37,6 @@ export default function Header() {
- {user?.role === "admin" && ( - - - Admin - - )} {user?.id && typeof user.id === "number" && } {user?.elo != null && typeof user.id === "number" && ( @@ -43,11 +44,57 @@ export default function Header() { )} -
); diff --git a/client/src/components/auth/AuthModal.tsx b/client/src/components/auth/AuthModal.tsx index ce9e8e7..6b64c94 100644 --- a/client/src/components/auth/AuthModal.tsx +++ b/client/src/components/auth/AuthModal.tsx @@ -1,12 +1,10 @@ "use client"; import { SessionContext } from "@/context/session"; -import { login, logout, register, setGuestSession } from "@/lib/auth"; -import Link from "next/link"; +import { login, register, setGuestSession } from "@/lib/auth"; import type { FormEvent } from "react"; import { useContext, useEffect, useRef, useState } from "react"; -import { IconSettings2, IconUserCircle } from "@tabler/icons-react"; import Guest from "./Guest"; import Login from "./Login"; import Register from "./Register"; @@ -18,15 +16,6 @@ export default function AuthModal() { const [buttonLoading, setButtonLoading] = useState(false); const modalToggleRef = useRef(null); - async function clickLogout() { - if (serverMessage) { - setServerMessage(null); - } - setActiveTab("login"); - await logout(); - session?.setUser(null); - } - async function submitAuth(e: FormEvent) { e.preventDefault(); @@ -105,102 +94,65 @@ export default function AuthModal() { className={"modal" + (session?.user === null ? " modal-open" : "")} >