-
Notifications
You must be signed in to change notification settings - Fork 1
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
[FEAT] Task 리스트 조회 api 연결 #169
Changes from all commits
2032d67
b96148a
1c0c63b
d031c6d
2149c20
349b530
b6cf8c1
ff63176
9ce2313
ba73d5d
7c2e803
0b628ab
453e000
7bccda6
050593f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import Router from './Router'; | ||
import Router from './router/Router'; | ||
|
||
function App() { | ||
return <Router />; | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface GetTasksType { | ||
isTotal?: boolean; | ||
sortOrder?: string; | ||
targetDate?: Date; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { GetTasksType } from './GetTasksType'; | ||
|
||
import { privateInstance } from '@/apis/instance'; | ||
|
||
const getTasks = async ({ isTotal, sortOrder, targetDate }: GetTasksType) => { | ||
const { data } = await privateInstance.get('/api/tasks', { | ||
params: { | ||
isTotal, | ||
order: sortOrder, | ||
targetDate, | ||
}, | ||
}); | ||
return data; | ||
}; | ||
|
||
export default getTasks; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import getTasks from './axios'; | ||
import { GetTasksType } from './GetTasksType'; | ||
|
||
/** Task 리스트 조회 */ | ||
const useGetTasks = ({ isTotal, sortOrder, targetDate }: GetTasksType) => | ||
useQuery({ | ||
queryKey: ['today', isTotal, sortOrder, targetDate], | ||
queryFn: () => getTasks({ isTotal, sortOrder, targetDate }), | ||
}); | ||
Comment on lines
+6
to
+11
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. 요런 식으로 리액트 쿼리를 사용하는 거군요,, 처음 써보기에 좀 막막한데요오 먼저 잘 정리해주셔서 잘 참고할 수 있을 것 같습니다! 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. today 페이지에서 사용해서 페이지별로 구분하면 이해하기 빠를 것 같아서 앞에 써주었습니다! 소팅하는 건 getTasks로 전달하는 요소들 중 두번째에서 담당하고 있어요! |
||
|
||
export default useGetTasks; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import styled from '@emotion/styled'; | ||
import { useGoogleLogin } from '@react-oauth/google'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
import userLogin from '@/apis/login/loginAxios'; | ||
import Images from '@/assets/images'; | ||
|
||
function GoogleLoginBtn() { | ||
const navigate = useNavigate(); | ||
const googleSocialLogin = useGoogleLogin({ | ||
onSuccess: async ({ code }) => { | ||
try { | ||
const response = await userLogin(code); | ||
if (response.code === 'success') { | ||
localStorage.setItem('accessToken', response.data.accessToken); | ||
localStorage.setItem('refreshToken', response.data.refreshToken); | ||
navigate('/today'); | ||
} | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}, | ||
onError: (errorResponse) => { | ||
console.error(errorResponse); | ||
}, | ||
flow: 'auth-code', | ||
scope: 'email profile', | ||
}); | ||
return ( | ||
<GoogleBtn onClick={googleSocialLogin}> | ||
<GoogleImg src={Images.googleIcon} /> | ||
구글 계정으로 시작하기 | ||
</GoogleBtn> | ||
); | ||
} | ||
const GoogleBtn = styled.button` | ||
display: flex; | ||
gap: 0.9rem; | ||
align-items: center; | ||
justify-content: center; | ||
width: 100%; | ||
height: 4.3rem; | ||
|
||
color: ${({ theme }) => theme.palette.Grey.White}; | ||
|
||
background-color: ${({ theme }) => theme.palette.Grey.Black}; | ||
border-radius: 12px; | ||
${({ theme }) => theme.fontTheme.LABEL_03}; | ||
`; | ||
const GoogleImg = styled.img` | ||
width: 1.8rem; | ||
height: 1.8rem; | ||
`; | ||
export default GoogleLoginBtn; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
const SORT_BY = { | ||
NEWEST: '최신 등록순', | ||
OLDEST: '오래된 등록순', | ||
CLOSEST: '지연된 할 일', | ||
CLOSEST: '가까운 마감기한순', | ||
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. 😂 |
||
FARTHEST: '먼 마감기한순', | ||
}; | ||
|
||
|
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.
요건 걍 궁금한건데 order는 왜 sortOrder로 한번 더 명명해준건가용??
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.
state 이름을 order로 지으면 구분하기가 다소 모호한데 서버에서 요구하는 path variable 에서는 order로 명명되어 있어서 한번 바꿔서 전달해줬습니다!