Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions frontend/src/components/TopNav.css
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,15 @@
font-weight: 700;
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}
/* 로그아웃은 버튼이라 기본 테두리와 배경을 지운다 */
button.fq-top-login {
border: 0;
background: transparent;
color: #fff;
font-family: inherit;
line-height: inherit;
cursor: pointer;
}

/* 본 화면. 제목 줄과 본문이 같은 좌우 여백을 쓴다 */
.u040 > .u040-main {
Expand Down
24 changes: 19 additions & 5 deletions frontend/src/components/TopNav.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import Link from "next/link";
import { usePathname } from "next/navigation";
import { usePathname, useRouter } from "next/navigation";
import { useEffect, useState } from "react";
import { useAuth } from "@/lib/auth";
import Constellation from "./Constellation";
Expand Down Expand Up @@ -35,7 +35,8 @@ function activePage(pathname: string) {

export default function TopNav({ children }: { children: React.ReactNode }) {
const pathname = usePathname();
const { profile, ready } = useAuth();
const router = useRouter();
const { profile, ready, logout } = useAuth();
const allowedAdmin = profile?.role === "ADMIN" || profile?.role === "ORGANIZER";
const menu = PAGES.filter((p) => p.menu && (p.href !== "/admin" || (ready && allowedAdmin)));
const current = activePage(pathname);
Expand Down Expand Up @@ -81,9 +82,22 @@ export default function TopNav({ children }: { children: React.ReactNode }) {
<IntroToggle className="fq-top-icon" />
<NotificationBell />
{profile ? (
<Link href="/me" className="fq-top-me" aria-label={`${profile.nickname}, 마이페이지`} aria-current={current.href === "/me" ? "page" : undefined}>
<i aria-hidden="true" />
</Link>
<>
<Link href="/me" className="fq-top-me" aria-label={`${profile.nickname}, 마이페이지`} aria-current={current.href === "/me" ? "page" : undefined}>
<i aria-hidden="true" />
</Link>
{/* 로그인 버튼과 같은 자리, 맨 오른쪽에 둔다 */}
<button
type="button"
className="fq-top-login"
onClick={async () => {
await logout();
router.push("/home");
}}
>
로그아웃
</button>
</>
) : (
<Link href="/login" className="fq-top-login">
{ready ? "로그인" : "…"}
Expand Down
Loading