11import useModalState from "@/hooks/useModalState" ;
22import useOutsideClick from "@/hooks/useOutsideClick" ;
33import useAuthStore from "@/store/authStore" ;
4- import { ModalState } from "@/types/ModalState" ;
54import Image from "next/image" ;
65import Link from "next/link" ;
76import { useRouter } from "next/navigation" ;
@@ -10,10 +9,11 @@ import UserImage from "./UserImage";
109
1110const UserDropDown = ( ) => {
1211 const authStore = useAuthStore ( ) ;
13- const modalState = useModalState ( ) ;
12+ const modalState = useModalState ( ) ;
1413 const router = useRouter ( ) ;
1514 const ref = useRef < any > ( ) ;
1615 const ref1 = useRef < any > ( ) ;
16+
1717 const logoutHandler = async ( ) => {
1818 // api로 로그아웃 요청해서 쿠키제거
1919 const response = await fetch ( "/api/auth/logout" , {
@@ -23,6 +23,7 @@ const UserDropDown = () => {
2323 if ( ! response . ok ) {
2424 throw new Error ( response . statusText ) ;
2525 }
26+
2627 authStore . initialize ( ) ;
2728 router . push ( "/" ) ;
2829 router . refresh ( ) ;
@@ -34,7 +35,7 @@ const UserDropDown = () => {
3435
3536 return (
3637 < button
37- className = "flex items-center gap-x-2 w-full "
38+ className = "flex w-full items-center gap-x-2"
3839 onClick = { ( e ) => {
3940 if ( ! modalState . isOpen ) {
4041 modalState . openModal ( ) ;
@@ -44,7 +45,10 @@ const UserDropDown = () => {
4445 // 클릭된 요소가 ref 요소 내부에 포함되지 않으면
4546 if ( ! ref . current . contains ( e . target as Node ) ) {
4647 modalState . closeModal ( ) ;
47- } else if ( ref . current . contains ( e . target as Node ) && ! ref1 . current . contains ( e . target as Node ) ) {
48+ } else if (
49+ ref . current . contains ( e . target as Node ) &&
50+ ! ref1 . current . contains ( e . target as Node )
51+ ) {
4852 modalState . closeModal ( ) ;
4953 }
5054 }
@@ -60,45 +64,46 @@ const UserDropDown = () => {
6064 < span className = "overflow-hidden text-ellipsis whitespace-nowrap font-bold" >
6165 { authStore . nickname }
6266 </ span >
63- {
64- modalState . isOpen &&
67+ { modalState . isOpen && (
6568 < section
6669 ref = { ref1 }
67- onClick = { ( e ) => e . preventDefault ( ) }
68- className = { "fixed right-0 top-[4rem] gap-y-4 p-4 rounded-2xl h-auto bg-white w-[20rem] flex flex-col outline outline-[0.0625rem] outline-offset-[-0.0625rem] outline-primary-20 outline-gray2 cursor-default" } >
69- < div className = "relative w-full flex justify-center h-[12rem] items-center p-4 rounded-[1rem] " >
70+ onClick = { ( e ) => e . preventDefault ( ) }
71+ className = "outline-primary-20 fixed right-0 top-[4rem] flex h-auto w-[20rem] cursor-default flex-col gap-y-4 rounded-2xl bg-white p-4 outline outline-[0.0625rem] outline-offset-[-0.0625rem] outline-gray2"
72+ >
73+ < div className = "relative flex h-[12rem] w-full items-center justify-center p-4" >
7074 < Image
75+ className = "rounded-full border-[0.03125rem] border-[#B8EDD9] bg-lightGreen"
7176 src = { authStore . userImage . address }
72- alt = { "유저 이미지" }
77+ alt = "유저 이미지"
7378 width = { 140 }
7479 height = { 140 }
7580 />
7681 </ div >
7782 < Link
78- href = { "/mypage?mainCategory=정보&category=owner" }
79- className = { "flex gap-x-2 items-center px-8 py-2 justify-center bg-white outline outline-[0.0625rem] outline-offset-[-0.0625rem] outline-gray3 outline-primary-20 rounded-[1rem]" }
83+ href = "/mypage?mainCategory=정보& category = owner "
84+ className = "outline-primary-20 flex items-center justify-center gap-x-2 rounded-[1rem] bg-white px-8 py-2 outline outline-[0.0625rem] outline-offset-[-0.0625rem] outline-gray3"
8085 onClick = { ( ) => modalState . closeModal ( ) }
8186 prefetch = { true }
8287 >
83- < div className = { "relative w -[1.25rem] h -[1.25rem]" } >
88+ < div className = "relative h -[1.25rem] w -[1.25rem]" >
8489 < Image
8590 className = "aspect-square"
8691 src = "/home/mypage-icon.svg"
8792 alt = "signin-icon"
8893 fill
8994 />
9095 </ div >
91- 마이페이지
96+ 마이페이지
9297 </ Link >
9398 < button
9499 onClick = { logoutHandler }
95- className = "px-8 py-2 bg-main rounded-2xl font-semibold text-white"
100+ className = "rounded-2xl bg-main px-8 py-2 font-semibold text-white"
96101 >
97- 로그아웃
102+ 로그아웃
98103 </ button >
99- </ section >
100- }
104+ </ section >
105+ ) }
101106 </ button >
102107 ) ;
103108} ;
104- export default UserDropDown ;
109+ export default UserDropDown ;
0 commit comments