-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
255 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
client/src/hooks/queries/auth/useRequestGetKakaoClientId.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import {useQuery} from '@tanstack/react-query'; | ||
|
||
import {requestKakaoClientId} from '@apis/request/auth'; | ||
|
||
import QUERY_KEYS from '@constants/queryKeys'; | ||
|
||
const useRequestGetKakaoClientId = () => { | ||
const {refetch, ...rest} = useQuery({ | ||
queryKey: [QUERY_KEYS.kakaoClientId], | ||
queryFn: requestKakaoClientId, | ||
enabled: false, | ||
}); | ||
|
||
return { | ||
requestGetClientId: refetch, | ||
...rest, | ||
}; | ||
}; | ||
|
||
export default useRequestGetKakaoClientId; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {useQuery} from '@tanstack/react-query'; | ||
|
||
import {requestGetKakaoLogin} from '@apis/request/auth'; | ||
|
||
import QUERY_KEYS from '@constants/queryKeys'; | ||
|
||
const useRequestGetKakaoLogin = () => { | ||
const code = new URLSearchParams(location.search).get('code'); | ||
|
||
const {refetch, ...rest} = useQuery({ | ||
queryKey: [QUERY_KEYS.kakaoLogin, code], | ||
queryFn: () => requestGetKakaoLogin(code ?? ''), | ||
enabled: false, | ||
}); | ||
|
||
return { | ||
requestGetKakaoLogin: refetch, | ||
...rest, | ||
}; | ||
}; | ||
|
||
export default useRequestGetKakaoLogin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import {useEffect} from 'react'; | ||
import {useLocation, useNavigate} from 'react-router-dom'; | ||
|
||
import {useAuthStore} from '@store/authStore'; | ||
|
||
import getKakaoRedirectUrl from '@utils/getKakaoRedirectUrl'; | ||
|
||
import {ROUTER_URLS} from '@constants/routerUrls'; | ||
|
||
import useRequestGetKakaoClientId from './queries/auth/useRequestGetKakaoClientId'; | ||
import useAmplitude from './useAmplitude'; | ||
import useRequestGetKakaoLogin from './queries/auth/useRequestGetKakaoLogin'; | ||
|
||
const useLoginPage = () => { | ||
const navigate = useNavigate(); | ||
const location = useLocation(); | ||
const {trackStartCreateEvent} = useAmplitude(); | ||
const {updateAuth} = useAuthStore(); | ||
const {requestGetKakaoLogin} = useRequestGetKakaoLogin(); | ||
|
||
const {requestGetClientId} = useRequestGetKakaoClientId(); | ||
|
||
const goKakaoLogin = async () => { | ||
const queryResult = await requestGetClientId(); | ||
const clientId = queryResult.data?.clientId; | ||
|
||
const link = `https://kauth.kakao.com/oauth/authorize?client_id=${clientId}&redirect_uri=${getKakaoRedirectUrl()}&response_type=code`; | ||
window.location.href = link; | ||
}; | ||
|
||
const goNonLoginCreateEvent = () => { | ||
trackStartCreateEvent({login: false}); | ||
navigate(ROUTER_URLS.createEvent); | ||
}; | ||
|
||
useEffect(() => { | ||
if (location.search === '') return; | ||
|
||
const code = new URLSearchParams(location.search).get('code'); | ||
|
||
const kakaoLogin = async () => { | ||
if (code) { | ||
await requestGetKakaoLogin(); | ||
updateAuth(true); | ||
|
||
// 추후에 업데이트 하는 로직 필요 | ||
trackStartCreateEvent({login: true}); | ||
navigate(ROUTER_URLS.createEvent); | ||
} | ||
}; | ||
|
||
kakaoLogin(); | ||
}, [location.search]); | ||
|
||
return {goKakaoLogin, goNonLoginCreateEvent}; | ||
}; | ||
|
||
export default useLoginPage; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import {css} from '@emotion/react'; | ||
|
||
import {Theme} from '@components/Design/theme/theme.type'; | ||
|
||
export const hrStyle = (theme: Theme) => | ||
css({ | ||
width: '100%', | ||
height: 1, | ||
|
||
backgroundColor: theme.colors.tertiary, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import Image from '@components/Design/components/Image/Image'; | ||
|
||
import useLoginPage from '@hooks/useLoginPage'; | ||
|
||
import {Button, Flex, FunnelLayout, Icon, MainLayout, Text, TopNav, useTheme} from '@components/Design'; | ||
|
||
import getImageUrl from '@utils/getImageUrl'; | ||
|
||
import {hrStyle} from './LoginPage.style'; | ||
|
||
const LOGIN_COMMENT = `로그인을 하면 계좌번호를 저장하고\n이전 행사들을 쉽게 볼 수 있어요.`; | ||
|
||
const LoginPage = () => { | ||
const {theme} = useTheme(); | ||
|
||
const {goKakaoLogin, goNonLoginCreateEvent} = useLoginPage(); | ||
|
||
return ( | ||
<MainLayout backgroundColor="white"> | ||
<TopNav> | ||
<TopNav.Item displayName="뒤로가기" noEmphasis routePath="-1" /> | ||
</TopNav> | ||
<FunnelLayout> | ||
<Flex flexDirection="column" justifyContent="spaceBetween" height="100%"> | ||
<Flex flexDirection="column" justifyContent="center" alignItems="center" gap="1rem" margin="0 0 6rem 0"> | ||
<Image src={getImageUrl('heundeut', 'webp')} fallbackSrc={getImageUrl('heundeut', 'png')} width={109} /> | ||
<Text size="bodyBold" css={{whiteSpace: 'pre-line', textAlign: 'center'}}> | ||
{LOGIN_COMMENT} | ||
</Text> | ||
</Flex> | ||
<Flex flexDirection="column" gap="1rem" width="100%" padding="0 2rem" paddingInline="auto"> | ||
<Button variants="kakao" size="large" onClick={goKakaoLogin}> | ||
<Flex alignItems="center" gap="0.625rem"> | ||
<Icon iconType="kakao" /> | ||
카카오 로그인 | ||
</Flex> | ||
</Button> | ||
<hr css={hrStyle(theme)} /> | ||
<Button variants="secondary" size="large" onClick={goNonLoginCreateEvent}> | ||
비회원으로 진행하기 | ||
</Button> | ||
</Flex> | ||
</Flex> | ||
</FunnelLayout> | ||
</MainLayout> | ||
); | ||
}; | ||
|
||
export default LoginPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.