1- import { useNavigate } from 'react-router-dom' ;
1+ import { useEffect , useState } from 'react' ;
2+ import { useNavigate , useParams } from 'react-router-dom' ;
3+
4+ import { Button } from '@components/shared/Button' ;
5+
6+ import { theme } from '@styles/theme' ;
27
38import bellIcon from '@assets/bell.svg' ;
49import leftArrowIcon from '@assets/leftArrow.svg' ;
@@ -52,6 +57,28 @@ export const Header = ({
5257 navigate ( '/all-services' ) ;
5358 } ;
5459
60+ const handleLoginClick = ( ) => {
61+ navigate ( '/login' ) ;
62+ } ;
63+
64+ const url = useParams ( ) ;
65+ const [ isLogin , setIsLogin ] = useState ( false ) ;
66+ useEffect ( ( ) => {
67+ const loginInfo = localStorage . getItem ( 'LOGIN_INFO' ) ;
68+
69+ if ( ! loginInfo ) {
70+ setIsLogin ( false ) ;
71+ } else {
72+ const { refreshToken } = JSON . parse ( loginInfo ) ;
73+
74+ if ( ! refreshToken ) {
75+ setIsLogin ( false ) ;
76+ } else {
77+ setIsLogin ( true ) ;
78+ }
79+ }
80+ } , [ url ] ) ;
81+
5582 return (
5683 < >
5784 < HeaderBackground >
@@ -70,23 +97,43 @@ export const Header = ({
7097 </ BackwardWrapper >
7198 ) }
7299 { title === '' ? < > </ > : < Title > { title } </ Title > }
73- < RightSideContainer className = { isRightContainer ? '' : 'invisible' } >
74- < RightSideIconWrapper >
75- < RightSideIcon onClick = { ( ) => handleSearchIconClick ( ) } >
76- < img src = { searchIcon } alt = "" />
77- </ RightSideIcon >
78- </ RightSideIconWrapper >
79- < RightSideIconWrapper >
80- < RightSideIcon onClick = { ( ) => handleBellIconClick ( ) } >
81- < img src = { bellIcon } alt = "" />
82- </ RightSideIcon >
83- </ RightSideIconWrapper >
84- < RightSideIconWrapper >
85- < RightSideIcon onClick = { ( ) => handleProfileIconClick ( ) } >
86- < img src = { profileIcon } alt = "" />
87- </ RightSideIcon >
88- </ RightSideIconWrapper >
89- </ RightSideContainer >
100+ { isLogin ? (
101+ < RightSideContainer className = { isRightContainer ? '' : 'invisible' } >
102+ < RightSideIconWrapper >
103+ < RightSideIcon onClick = { ( ) => handleSearchIconClick ( ) } >
104+ < img src = { searchIcon } alt = "" />
105+ </ RightSideIcon >
106+ </ RightSideIconWrapper >
107+ < RightSideIconWrapper >
108+ < RightSideIcon onClick = { ( ) => handleBellIconClick ( ) } >
109+ < img src = { bellIcon } alt = "" />
110+ </ RightSideIcon >
111+ </ RightSideIconWrapper >
112+ < RightSideIconWrapper >
113+ < RightSideIcon onClick = { ( ) => handleProfileIconClick ( ) } >
114+ < img src = { profileIcon } alt = "" />
115+ </ RightSideIcon >
116+ </ RightSideIconWrapper >
117+ </ RightSideContainer >
118+ ) : (
119+ < RightSideContainer
120+ className = { isRightContainer ? '' : 'invisible' }
121+ isLogin = { true }
122+ >
123+ < Button
124+ width = "60px"
125+ height = "24px"
126+ fontWeight = { 300 }
127+ textColor = { theme . PALETTE . GRAY_600 }
128+ fontSize = { theme . FONT_SIZE . XS }
129+ backgroundColor = "white"
130+ borderColor = { theme . PALETTE . GRAY_600 }
131+ onClick = { handleLoginClick }
132+ >
133+ 로그인
134+ </ Button >
135+ </ RightSideContainer >
136+ ) }
90137 </ HeaderContainer >
91138 </ HeaderBackground >
92139 </ >
0 commit comments