From f062acd2f79bab6e561092ac34390f01c87050a3 Mon Sep 17 00:00:00 2001 From: llddang <77055208+llddang@users.noreply.github.com> Date: Fri, 27 Sep 2024 21:56:50 +0900 Subject: [PATCH] =?UTF-8?q?Feature/#325=20=EB=A1=9C=EA=B7=B8=EC=95=84?= =?UTF-8?q?=EC=9B=83=EC=8B=9C=20=EB=A9=94=EC=9D=B8=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=EB=A1=9C=20=EC=9D=B4=EB=8F=99=20(#326)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 로그아웃 핸들러 함수로 구현 #325 * feat: 로그아웃 버튼 클릭시 메인페이지로 이동하도록 로직 추가 #325 --- src/components/Sidebar/SidebarContent/index.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/Sidebar/SidebarContent/index.tsx b/src/components/Sidebar/SidebarContent/index.tsx index 3e3aca3..f58011f 100644 --- a/src/components/Sidebar/SidebarContent/index.tsx +++ b/src/components/Sidebar/SidebarContent/index.tsx @@ -2,6 +2,7 @@ import { Avatar, Button, Flex, IconButton, Text } from '@chakra-ui/react'; import { useSetAtom } from 'jotai'; +import { useRouter } from 'next/navigation'; import { useEffect, useState } from 'react'; import { BiBell, BiUser } from 'react-icons/bi'; import { BsPlus, BsGrid } from 'react-icons/bs'; @@ -18,11 +19,20 @@ import { SidebarContentProps, SidebarTeam } from '../type'; const SidebarContent = ({ isOpen, setIsOpen }: SidebarContentProps) => { const [isTeamModalOpen, setIsTeamModalOpen] = useState(false); + const user = useGetUser(); const setUser = useSetAtom(userAtom); const setMyTeams = useSetAtom(myTeamAtom); + + const router = useRouter(); + const { data: sidebarInfo } = useGetSideBarInfoQuery(); + const handleLogOutButtonClick = () => { + setUser(defaultUserAtom); + router.push('/'); + }; + useEffect(() => { const myTeams = sidebarInfo?.body.myTeamsAndStudies ? sidebarInfo.body.myTeamsAndStudies.map((team: { teamId: number }) => team.teamId) @@ -67,7 +77,7 @@ const SidebarContent = ({ isOpen, setIsOpen }: SidebarContentProps) => { } onClick={() => {}} /> } onClick={() => {}} /> - } onClick={() => setUser(defaultUserAtom)} /> + } onClick={handleLogOutButtonClick} /> {isOpen && user?.isLogin && (