diff --git a/src/components/Gnb.tsx b/src/components/Gnb.tsx
index b975a97e..c4ea9553 100644
--- a/src/components/Gnb.tsx
+++ b/src/components/Gnb.tsx
@@ -5,6 +5,7 @@ import Link from 'next/link';
import { usePathname, useRouter } from 'next/navigation';
import { useState } from 'react';
+import { UserProfile } from '@/api/types/auth';
import AlarmActive from '@/assets/icons/alarm_active.svg';
import AlarmInActive from '@/assets/icons/alarm_inactive.svg';
import useMyNotifyQuery from '@/hooks/myNotifications/useMyNotifyQuery';
@@ -20,19 +21,7 @@ const imgLogoText = '/images/logo-sm-text.png';
const imgLogo = '/images/logo-sm.png';
export default function Gnb() {
- const router = useRouter();
- const isMobile = useMediaQuery('mobile');
- const [isOpen, setIsOpen] = useState(false);
- const {
- data: notifications,
- hasNextPage,
- isFetchingNextPage,
- fetchNextPage,
- } = useMyNotifyQuery();
-
- const totalCount = notifications?.pages?.[0]?.totalCount || 0;
const user = useUserStore((s) => s.user);
- const clearUser = useUserStore((s) => s.clearUser);
const pathname = usePathname();
if (pathname === '/login' || pathname === '/signup') {
return null;
@@ -72,87 +61,102 @@ export default function Gnb() {
user ? 'gap-20' : 'gap-10 md:gap-12',
)}
>
- {user ? (
- <>
-
-
-
page.notifications,
- ) || []
- }
- open={isOpen}
- totalCount={totalCount}
- onClose={() => setIsOpen(false)}
- />
-
-
-
- router.push(isMobile ? '/mypage' : '/mypage/info'),
- },
- {
- text: '로그아웃',
- danger: true,
- onClick: () => {
- clearUser();
- router.push('/');
- },
- },
- ]}
- position='bottom'
- trigger={
-
-
- {user.nickname}
-
- }
- />
- >
- ) : (
- <>
-
- 로그인
-
-
- 회원가입
-
- >
- )}
+ {user ? : }
);
}
+
+function LoggedinButtons({ user }: { user: UserProfile }) {
+ const router = useRouter();
+ const isMobile = useMediaQuery('mobile');
+ const [isOpen, setIsOpen] = useState(false);
+ const clearUser = useUserStore((s) => s.clearUser);
+ const {
+ data: notifications,
+ hasNextPage,
+ isFetchingNextPage,
+ fetchNextPage,
+ } = useMyNotifyQuery();
+
+ const totalCount = notifications?.pages?.[0]?.totalCount || 0;
+
+ return (
+ <>
+
+
+
page.notifications) || []
+ }
+ open={isOpen}
+ totalCount={totalCount}
+ onClose={() => setIsOpen(false)}
+ />
+
+
+ router.push(isMobile ? '/mypage' : '/mypage/info'),
+ },
+ {
+ text: '로그아웃',
+ danger: true,
+ onClick: () => {
+ clearUser();
+ router.push('/');
+ },
+ },
+ ]}
+ position='bottom'
+ trigger={
+
+
+ {user.nickname}
+
+ }
+ />
+ >
+ );
+}
+
+function LoggedoutButtons() {
+ return (
+ <>
+
+ 로그인
+
+
+ 회원가입
+
+ >
+ );
+}