Skip to content

Commit 2835639

Browse files
committed
feat: 헤더에 로그인 버튼 추가
1 parent 3f98b02 commit 2835639

File tree

3 files changed

+68
-26
lines changed

3 files changed

+68
-26
lines changed

src/components/Header/Header.style.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ export const Title = styled.div`
7171
text-align: center;
7272
`;
7373

74-
export const RightSideContainer = styled.div`
74+
export const RightSideContainer = styled.div<{ isLogin?: boolean }>`
7575
width: 5.5rem;
7676
${({ theme }) => theme.STYLES.FLEX_JUSTIFY_CENTER}
77-
justify-content: space-between;
77+
justify-content:${({ isLogin }) => (isLogin ? 'flex-end' : 'space-between')};
7878
7979
&.invisible {
8080
visibility: hidden;

src/components/Header/Header.tsx

Lines changed: 65 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
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

38
import bellIcon from '@assets/bell.svg';
49
import 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
</>

src/pages/LoginPage/LoginPage.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,7 @@ const LOGIN_MAIN =
1717
'https://github.com/Java-and-Script/pickple-front/assets/87280835/1134921d-2e91-4b47-b99a-4095c91f0a6d';
1818

1919
export const LoginPage = () => {
20-
// const KAKAO_REST_API_KEY = import.meta.env.VITE_KAKAO_REST_API_KEY;
21-
// const KAKAO_REDIRECT_URI = import.meta.env.VITE_KAKAO_REDIRECT_URI;
22-
2320
const onClickKakaoLogin = async () => {
24-
// await fetch('https://dev.pickple.kr/auth/kakao');
25-
// window.location.href = `https://kauth.kakao.com/oauth/authorize?response_type=code&client_id=${KAKAO_REST_API_KEY}&redirect_uri=${KAKAO_REDIRECT_URI}`;
2621
getAuthRedirect({ oauthProvider: 'KAKAO' });
2722
};
2823

@@ -42,7 +37,7 @@ export const LoginPage = () => {
4237
width="100%"
4338
height="auto"
4439
alt="kakao login"
45-
onClick={() => onClickKakaoLogin()}
40+
onClick={onClickKakaoLogin}
4641
/>
4742
</Main>
4843
</LoginContainer>

0 commit comments

Comments
 (0)