From 9d5e6fd08d785007d835c9457a9cf1817f41ef5d Mon Sep 17 00:00:00 2001 From: soyeong Date: Fri, 27 Feb 2026 17:47:32 +0900 Subject: [PATCH] =?UTF-8?q?feat(SCRUM-437):=20=EB=A1=9C=EA=B7=B8=EC=9D=B8?= =?UTF-8?q?=20=EC=82=AC=EC=9A=A9=EC=9E=90=20=EB=8B=89=EB=84=A4=EC=9E=84=20?= =?UTF-8?q?=EB=AF=B8=EC=84=A4=EC=A0=95=20=EC=83=81=ED=83=9C=20=EA=B0=90?= =?UTF-8?q?=EC=A7=80=20=EB=B0=8F=20=EA=B0=95=EC=A0=9C=20=EB=A6=AC=EB=8B=A4?= =?UTF-8?q?=EC=9D=B4=EB=A0=89=ED=8A=B8=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/layout/AppLayout.tsx | 36 +++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/components/layout/AppLayout.tsx b/src/components/layout/AppLayout.tsx index d5a7cdb..392543c 100644 --- a/src/components/layout/AppLayout.tsx +++ b/src/components/layout/AppLayout.tsx @@ -1,5 +1,9 @@ -import { useLocation } from 'react-router-dom'; +import { useLocation, useNavigate } from 'react-router-dom'; +import { useEffect } from 'react'; +import { useSelector } from 'react-redux'; +import type { RootState } from '@/store'; import FloatingButton from '@/components/common/FloatingButton'; +import axiosInstance from '@/api/axiosInstance'; interface Props { children: React.ReactNode; @@ -7,10 +11,38 @@ interface Props { export default function AppLayout({ children }: Props) { const location = useLocation(); + const navigate = useNavigate(); + const isLoggedIn = useSelector((state: RootState) => state.user.isLoggedIn); const isCommunityPage = location.pathname === '/community'; + // 로그인 상태일 때 nickname 체크 및 리다이렉트 + useEffect(() => { + const checkUserNickname = async () => { + if ( + !isLoggedIn || + location.pathname === '/nickname' || + location.pathname === '/login' + ) { + return; + } + + try { + const response = await axiosInstance.get('/api/v1/user/nickname'); + const nickname = response.data.results?.nickname; + + if (!nickname) { + navigate('/nickname', { replace: true }); + } + } catch (error) { + console.error('사용자 정보 확인 실패:', error); + } + }; + + checkUserNickname(); + }, [isLoggedIn, location.pathname, navigate]); + return ( -
+
{/* 스크롤 가능한 콘텐츠 영역 */}