-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[코드리뷰] 9주차 작업 #139
[코드리뷰] 9주차 작업 #139
Changes from all commits
b252959
1175dab
cd28e1b
c9635c2
c6e6358
659215d
244ee5c
a985eee
fe3f4fc
4e4786d
dd0150a
1b1b662
5a69d95
d66d9bd
1b8f336
2f8a06d
dfbebcd
1333692
cea950a
ae4179e
ecb4c57
57695e6
4779e98
8b4b5d5
3f4413a
986475a
7a14ba1
27a4efd
d1b47e7
32d9e7c
a2d721a
c2222e1
708540a
ac32c7a
ae23c2b
03c46ee
f99f849
12a286c
488ec4b
d60e550
102e3bc
39060e6
db46eb4
e4a2c7c
988ef96
1390aec
d19a5c5
1ba7d69
38b3f56
dc4da7b
33f04c5
ffe09c6
7344598
d9fd1c8
34a0a5b
ff10437
49c525d
3ab7156
ec8fe5d
ccc2437
cde90cc
3f7c1a6
67ea9f2
c9e6012
46cbf65
4a1c383
df9a6eb
c381661
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ node_modules | |
.vscode | ||
.github | ||
dist | ||
|
||
pnpm-lock.yaml |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
"@tanstack/react-query": "^5.51.11", | ||
"axios": "^1.7.5", | ||
"date-fns": "^4.1.0", | ||
"dayjs": "^1.11.13", | ||
"msw": "^2.3.5", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이제보니까 msw가 dependencies에 있네요..! |
||
"react": "^18.3.1", | ||
"react-datepicker": "^7.4.0", | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,9 @@ import { Routes } from '@/app/routes'; | |
import { | ||
AllSeniorInfoProvider, | ||
queryClient, | ||
AuthProvider, | ||
UserEmailProvider, | ||
globalStyle, | ||
SinittoInfoProvider, | ||
} from '@/shared'; | ||
import { ChakraProvider } from '@chakra-ui/react'; | ||
import { Global } from '@emotion/react'; | ||
|
@@ -14,10 +15,12 @@ const App = () => { | |
<ChakraProvider> | ||
<QueryClientProvider client={queryClient}> | ||
<AllSeniorInfoProvider> | ||
<AuthProvider> | ||
<Global styles={globalStyle} /> | ||
<Routes /> | ||
</AuthProvider> | ||
<SinittoInfoProvider> | ||
<UserEmailProvider> | ||
<Global styles={globalStyle} /> | ||
<Routes /> | ||
</UserEmailProvider> | ||
</SinittoInfoProvider> | ||
</AllSeniorInfoProvider> | ||
</QueryClientProvider> | ||
</ChakraProvider> | ||
Comment on lines
15
to
26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
const Providers = createProviders([
ChakraProvider,
[QueryClientProvider, { client: queryClient }],
AllSeniorInfoProvider,
SinittoInfoProvider,
UserEmailProvider,
])
const App = () => {
<Providers>
<Global styles={globalStyle} />
<Routes />
</Providers>
} |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
import { RouterPath } from '@/app/routes'; | ||
import { Box, Text, Spinner, Heading } from '@chakra-ui/react'; | ||
|
||
export const DummyRedirectPage = () => { | ||
const [statusMessage, setStatusMessage] = useState( | ||
'유저 정보를 기다리고 있습니다...' | ||
); | ||
const [isLoading, setIsLoading] = useState(true); | ||
const navigate = useNavigate(); | ||
|
||
useEffect(() => { | ||
const params = new URLSearchParams(window.location.search); | ||
|
||
const accessToken = params.get('accessToken'); | ||
const refreshToken = params.get('refreshToken'); | ||
const isSinitto = params.get('isSinitto'); | ||
|
||
if (accessToken && refreshToken && isSinitto) { | ||
// 로컬 스토리지에 토큰 저장 | ||
localStorage.setItem('accessToken', accessToken); | ||
localStorage.setItem('refreshToken', refreshToken); | ||
localStorage.setItem('isSinitto', isSinitto); | ||
Comment on lines
+22
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 로컬 스토리지를 다룬 로직은 추상화해주면 좋을 것 같아요! |
||
|
||
// isSinitto 상태에 따른 메시지 설정 | ||
setStatusMessage( | ||
isSinitto === 'true' | ||
? '시니또 더미데이터로 로그인 중입니다. 페이지 이동 중...' | ||
: '보호자 더미데이터로 로그인 중입니다. 페이지 이동 중...' | ||
); | ||
|
||
setTimeout(() => { | ||
setIsLoading(false); // 로딩 완료 | ||
navigate(isSinitto === 'true' ? RouterPath.SINITTO : RouterPath.GUARD); | ||
}, 2000); | ||
} else { | ||
console.error('Access or Refresh token not found in query parameters.'); | ||
setStatusMessage('[ERROR] 토큰이 존재하지 않습니다.'); | ||
|
||
setIsLoading(false); | ||
} | ||
}, [navigate]); | ||
|
||
return ( | ||
<Box textAlign='center' mt='50px'> | ||
<Heading as='h1' size='lg' mb='1rem'> | ||
더미데이터 로그인 | ||
</Heading> | ||
<Text fontSize='lg'>{statusMessage}</Text> | ||
{(isLoading || statusMessage === '유저 정보를 기다리고 있습니다...') && ( | ||
<Spinner size='lg' mt='1rem' /> | ||
)} | ||
</Box> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { DummyRedirectPage } from './DummyRedirectPage'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './dummy-redirect'; | ||
export * from './main'; | ||
export * from './redirect'; | ||
export * from './register'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
import { Link } from 'react-router-dom'; | ||
|
||
import Logo from '../../assets/kakao.svg'; | ||
import { KAKAO_AUTH_URL } from '@/shared/utils/env/config'; | ||
import Logo from '@/pages/assets/main/kakao.svg'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pages에서 pages에 있는걸 가져오게 되면 순환참조가 될 수 있답니다..! |
||
import { BASE_URI } from '@/shared/api'; | ||
import { Image, Text } from '@chakra-ui/react'; | ||
import styled from '@emotion/styled'; | ||
|
||
const LoginButton = () => { | ||
const KAKAO_LOGIN = `${BASE_URI}/api/auth/oauth/kakao`; | ||
|
||
return ( | ||
<Link to={KAKAO_AUTH_URL}> | ||
<Link to={KAKAO_LOGIN}> | ||
<KakaoLoginButton> | ||
<Image src={Logo} alt='kakao-icon' /> | ||
<Text fontWeight='500'>카카오톡 로그인</Text> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ import { AxiosError } from 'axios'; | |
|
||
import { registerUser, SignupApiResponse } from '../api'; | ||
import { RouterPath } from '@/app/routes/path'; | ||
import { authLocalStorage } from '@/shared/utils/storage'; | ||
import { authStorage } from '@/shared/utils/storage'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
|
||
const useRegister = () => { | ||
|
@@ -16,10 +16,10 @@ const useRegister = () => { | |
} else { | ||
console.log(data); | ||
if ('accessToken' in data) { | ||
authLocalStorage.set(data.accessToken); | ||
authLocalStorage.set(data.refreshToken); | ||
authStorage.accessToken.set(data.accessToken); | ||
authStorage.refreshToken.set(data.refreshToken); | ||
Comment on lines
+19
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 여기서는 스토리지를 추상화해서 사용하고 있네요..!? |
||
alert('회원가입이 완료되었습니다.'); | ||
navigate(data.isSinitto === 'true' ? RouterPath.ROOT : RouterPath.ROOT); | ||
navigate(data.isSinitto ? RouterPath.SINITTO : RouterPath.GUARD); | ||
} | ||
} | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이렇게 하면 pnpm 따로 설치하지 않아도 된답니다!