From c16c8813c73d5c1da0c40fbba7d620551557b748 Mon Sep 17 00:00:00 2001 From: KimKyuHoi Date: Wed, 29 May 2024 07:24:39 +0900 Subject: [PATCH 1/8] =?UTF-8?q?rename:=20=ED=8C=8C=EC=9D=BC=20=ED=99=95?= =?UTF-8?q?=EC=9E=A5=EC=9E=90=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/src/services/search/getGroups.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 front/src/services/search/getGroups.ts diff --git a/front/src/services/search/getGroups.ts b/front/src/services/search/getGroups.ts new file mode 100644 index 0000000..0274a28 --- /dev/null +++ b/front/src/services/search/getGroups.ts @@ -0,0 +1,13 @@ +import { BASE_URI } from '@constants/URI'; + +import { instance } from '@services/API_JWT'; + +export const getGroups = async () => { + try { + const response = await instance.get(`${BASE_URI}/groups`); + return response.data; + } catch (error) { + console.error('Error fetching groups Try Again:', error); + throw error; + } +}; From 77438619578564a65883b6bb5b05c1e612c630f0 Mon Sep 17 00:00:00 2001 From: KimKyuHoi Date: Wed, 29 May 2024 07:24:59 +0900 Subject: [PATCH 2/8] =?UTF-8?q?feat:=20UserData=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/src/hooks/queries/feed/getUserDataQuery.ts | 13 +++++++++++++ front/src/services/feed/getUserData.ts | 13 +++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 front/src/hooks/queries/feed/getUserDataQuery.ts create mode 100644 front/src/services/feed/getUserData.ts diff --git a/front/src/hooks/queries/feed/getUserDataQuery.ts b/front/src/hooks/queries/feed/getUserDataQuery.ts new file mode 100644 index 0000000..b810f44 --- /dev/null +++ b/front/src/hooks/queries/feed/getUserDataQuery.ts @@ -0,0 +1,13 @@ +import { getUserData } from '@services/feed/getUserData'; + +import { useQuery } from '@tanstack/react-query'; + +export const useUserData = () => { + const { data, isPending, isError, error } = useQuery({ + queryKey: ['users'], + queryFn: getUserData, + refetchOnMount: false, + }); + + return { data, isPending, isError, error }; +}; diff --git a/front/src/services/feed/getUserData.ts b/front/src/services/feed/getUserData.ts new file mode 100644 index 0000000..aea2801 --- /dev/null +++ b/front/src/services/feed/getUserData.ts @@ -0,0 +1,13 @@ +import { BASE_URI } from '@constants/URI'; + +import { instance } from '@services/API_JWT'; + +export const getUserData = async () => { + try { + const response = await instance.get(`${BASE_URI}/users`); + return response.data; + } catch (error) { + console.error('Error fetching UserData:', error); + throw error; + } +}; From f0a3310359086996f3768ff5b679a77ef654155a Mon Sep 17 00:00:00 2001 From: KimKyuHoi Date: Wed, 29 May 2024 07:26:02 +0900 Subject: [PATCH 3/8] =?UTF-8?q?feat:=20=EC=BB=A4=EB=B0=8B=20=EA=B0=9C?= =?UTF-8?q?=EC=88=98=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/src/hooks/queries/feed/getUserCommitQuery.ts | 13 +++++++++++++ front/src/services/feed/getUserCommit.ts | 13 +++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 front/src/hooks/queries/feed/getUserCommitQuery.ts create mode 100644 front/src/services/feed/getUserCommit.ts diff --git a/front/src/hooks/queries/feed/getUserCommitQuery.ts b/front/src/hooks/queries/feed/getUserCommitQuery.ts new file mode 100644 index 0000000..c8f9b5a --- /dev/null +++ b/front/src/hooks/queries/feed/getUserCommitQuery.ts @@ -0,0 +1,13 @@ +import { getUserCommit } from '@services/feed/getUserCommit'; + +import { useQuery } from '@tanstack/react-query'; + +export const useCommits = () => { + const { data, isPending, isError, error } = useQuery({ + queryKey: ['user_commit'], + queryFn: getUserCommit, + refetchOnMount: false, + }); + + return { data, isPending, isError, error }; +}; diff --git a/front/src/services/feed/getUserCommit.ts b/front/src/services/feed/getUserCommit.ts new file mode 100644 index 0000000..7cb2a09 --- /dev/null +++ b/front/src/services/feed/getUserCommit.ts @@ -0,0 +1,13 @@ +import { BASE_URI } from '@constants/URI'; + +import { instance } from '@services/API_JWT'; + +export const getUserCommit = async () => { + try { + const response = await instance.get(`${BASE_URI}/problems/count`); + return response.data; + } catch (error) { + console.error('Error fetching UserData:', error); + throw error; + } +}; From 35e5fef00a62b046fe6e69c0f328e3ecd66ae588 Mon Sep 17 00:00:00 2001 From: KimKyuHoi Date: Wed, 29 May 2024 07:26:24 +0900 Subject: [PATCH 4/8] =?UTF-8?q?feat:=20problem=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/src/hooks/queries/feed/getProblems.ts | 13 +++++++++++++ front/src/interfaces/ProblemInterface.ts | 6 ++++++ front/src/pages/feed/components/ProblemList.tsx | 16 ++++++---------- front/src/services/feed/getProblems.ts | 13 +++++++++++++ 4 files changed, 38 insertions(+), 10 deletions(-) create mode 100644 front/src/hooks/queries/feed/getProblems.ts create mode 100644 front/src/interfaces/ProblemInterface.ts create mode 100644 front/src/services/feed/getProblems.ts diff --git a/front/src/hooks/queries/feed/getProblems.ts b/front/src/hooks/queries/feed/getProblems.ts new file mode 100644 index 0000000..7e27b84 --- /dev/null +++ b/front/src/hooks/queries/feed/getProblems.ts @@ -0,0 +1,13 @@ +import { getUserProblems } from '@services/feed/getProblems'; + +import { useQuery } from '@tanstack/react-query'; + +export const useProblem = () => { + const { data, isPending, isError, error } = useQuery({ + queryKey: ['userProblems'], + queryFn: getUserProblems, + refetchOnMount: false, + }); + + return { data, isPending, isError, error }; +}; diff --git a/front/src/interfaces/ProblemInterface.ts b/front/src/interfaces/ProblemInterface.ts new file mode 100644 index 0000000..e7132ee --- /dev/null +++ b/front/src/interfaces/ProblemInterface.ts @@ -0,0 +1,6 @@ +export interface IProblem { + solvedDate: string; + commitUrl: string; + title: string; + rank: string; +} diff --git a/front/src/pages/feed/components/ProblemList.tsx b/front/src/pages/feed/components/ProblemList.tsx index b15a346..00420ce 100644 --- a/front/src/pages/feed/components/ProblemList.tsx +++ b/front/src/pages/feed/components/ProblemList.tsx @@ -1,13 +1,9 @@ import { ButtonWrapper } from '@components/button/ButtonWrapper'; import { DefaultButton } from '@components/button/DefaultButton'; -import styled from '@emotion/styled'; +import { IProblem } from '@interfaces/ProblemInterface'; -interface IProblem { - date: string; - problem: string; - difficulty: string; -} +import styled from '@emotion/styled'; const ProblemContainer = styled.div` background: linear-gradient( @@ -101,15 +97,15 @@ const ProblemList = ({ {problems - .filter((problem) => problem.date === formattedDate) + .filter((problem) => problem.solvedDate === formattedDate) .map((problem, index) => ( - {problem.problem} - {problem.difficulty} + {problem.title} + {problem.rank} alert('click')} + onClick={() => window.open(problem.commitUrl)} color='white' backgroundColor='blue' > diff --git a/front/src/services/feed/getProblems.ts b/front/src/services/feed/getProblems.ts new file mode 100644 index 0000000..b8602c8 --- /dev/null +++ b/front/src/services/feed/getProblems.ts @@ -0,0 +1,13 @@ +import { BASE_URI } from '@constants/URI'; + +import { instance } from '@services/API_JWT'; + +export const getUserProblems = async () => { + try { + const response = await instance.get(`${BASE_URI}/problems`); + return response.data; + } catch (error) { + console.error('Error fetching UserData:', error); + throw error; + } +}; From 08c54f2fd953856fa4470fbd8879fa8585db0a6a Mon Sep 17 00:00:00 2001 From: KimKyuHoi Date: Wed, 29 May 2024 07:26:47 +0900 Subject: [PATCH 5/8] =?UTF-8?q?feat:=20=ED=94=84=EB=A1=9C=ED=95=84=20?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/src/pages/feed/components/Profile.tsx | 118 ++++++++++++-------- 1 file changed, 71 insertions(+), 47 deletions(-) diff --git a/front/src/pages/feed/components/Profile.tsx b/front/src/pages/feed/components/Profile.tsx index c901f64..6d22f53 100644 --- a/front/src/pages/feed/components/Profile.tsx +++ b/front/src/pages/feed/components/Profile.tsx @@ -1,13 +1,13 @@ -import { useEffect } from 'react'; - -import axios from 'axios'; - +// import { useEffect } from 'react'; +// import axios from 'axios'; import Text from '@components/typography/Text'; -import DefaultProfileImg from '@assets/HaedalProfile.png'; +import { useUserData } from '@hooks/queries/feed/getUserDataQuery'; -import { useUserDataStore } from '@stores/useUserDataStore'; +import DefaultProfileImg from '@assets/HaedalProfile.png'; +// import { useCommits } from '@/hooks/queries/feed/getUserCommitQuery'; +// import { useUserDataStore } from '@stores/useUserDataStore'; import styled from '@emotion/styled'; const ProfileLayout = styled.div` @@ -34,56 +34,80 @@ const ProfileTextLayout = styled.div` const Profile = () => { const { - setUsername, - getUsername, - setProfileImg, - getProfileImg, - setCommit, - getCommit, - } = useUserDataStore(); - const username = getUsername(); - const commitNum = getCommit(); - const profileImg = getProfileImg(); + data: userData, + isPending: userPending, + isError: userError, + } = useUserData(); + // const { data: commit } = useCommits(); + const username = userData?.loginId || ''; + const profileImg = userData?.profileUrl || DefaultProfileImg; + // const commitNum = commit?.commit || 0; + + // console.log('commit', commit); + // MSW Test CODE + // const { + // setUsername, + // getUsername, + // setProfileImg, + // getProfileImg, + // setCommit, + // getCommit, + // } = useUserDataStore(); + // const username = getUsername(); + // const commitNum = getCommit(); + // const profileImg = getProfileImg(); - useEffect(() => { - const fetchProfile = async () => { - try { - const res = await axios.get('/api/profile'); - setUsername(res.data.name); - setProfileImg(res.data.url); - console.log(res.data.url); - } catch (e) { - console.error('Error fetching profile:', e); - } - }; + // useEffect(() => { + // const fetchProfile = async () => { + // try { + // const res = await axios.get('/api/profile'); + // setUsername(res.data.name); + // setProfileImg(res.data.url); + // console.log(res.data.url); + // } catch (e) { + // console.error('Error fetching profile:', e); + // } + // }; - fetchProfile(); - }, [setUsername, setProfileImg]); + // fetchProfile(); + // }, [setUsername, setProfileImg]); - useEffect(() => { - const fetchCommit = async () => { - try { - const res = await axios.get('/api/commit'); - setCommit(res.data.commit); - } catch (e) { - console.error('Error fetching commit:', e); - } - }; + // useEffect(() => { + // const fetchCommit = async () => { + // try { + // const res = await axios.get('/api/commit'); + // setCommit(res.data.commit); + // } catch (e) { + // console.error('Error fetching commit:', e); + // } + // }; - fetchCommit(); - }, [setCommit]); + // fetchCommit(); + // }, [setCommit]); return ( <> - + - - {username}님 반갑습니다! - - - 오늘의 커밋 개수는 {commitNum}개 입니다. - + {userPending ? ( + + Loading... + + ) : userError ? ( + + 네트워크 오류입니다. + + ) : ( + <> + + {username}님 반갑습니다! + + + 오늘의 커밋 개수는 0개 입니다. + + + )} From 660bc400de8f70691a4eb4b32a754ba815364424 Mon Sep 17 00:00:00 2001 From: KimKyuHoi Date: Wed, 29 May 2024 07:27:06 +0900 Subject: [PATCH 6/8] =?UTF-8?q?remove:=20=ED=8C=8C=EC=9D=BC=20=ED=99=95?= =?UTF-8?q?=EC=9E=A5=EC=9E=90=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/src/services/search/getGroups.tsx | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 front/src/services/search/getGroups.tsx diff --git a/front/src/services/search/getGroups.tsx b/front/src/services/search/getGroups.tsx deleted file mode 100644 index 287ed33..0000000 --- a/front/src/services/search/getGroups.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { BASE_URI } from '@constants/URI'; - -import { instance } from '@services/API_JWT'; - -export const getGroups = async () => { - try { - const response = await instance.get(`${BASE_URI}/groups`); - return response.data; - } catch (error) { - console.error('Error fetching groups:', error); - throw error; - } -}; From a1946186420efc36f9919450adec8eaf81710ac0 Mon Sep 17 00:00:00 2001 From: KimKyuHoi Date: Wed, 29 May 2024 07:27:29 +0900 Subject: [PATCH 7/8] =?UTF-8?q?feat:=20=ED=86=A0=ED=81=B0=20=EC=9C=A0?= =?UTF-8?q?=EB=AC=B4=EC=97=90=20=EB=94=B0=EB=9D=BC=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=A0=91=EA=B7=BC=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/src/pages/feed/FeedPage.tsx | 160 ++++++++++++++++---------- front/src/pages/search/SearchPage.tsx | 26 +++-- front/src/styles/Layout.ts | 7 ++ 3 files changed, 124 insertions(+), 69 deletions(-) diff --git a/front/src/pages/feed/FeedPage.tsx b/front/src/pages/feed/FeedPage.tsx index 4983faa..b8981f7 100644 --- a/front/src/pages/feed/FeedPage.tsx +++ b/front/src/pages/feed/FeedPage.tsx @@ -2,55 +2,62 @@ import 'react-calendar/dist/Calendar.css'; import dayjs from 'dayjs'; +import Text from '@components/typography/Text'; + import { StyleCalendar } from '@pages/feed/components/Calendar'; import ProblemList from '@pages/feed/components/ProblemList'; import Profile from '@pages/feed/components/Profile'; +import { useProblem } from '@hooks/queries/feed/getProblems'; + import { useFeedStore } from '@stores/useFeedStore'; +import { useTokenStore } from '@stores/useTokenStore'; -import { Layout, DisplayLayout } from '@styles/Layout'; +import { IProblem } from '@interfaces/ProblemInterface'; + +import { Layout, DisplayLayout, LoginLayout } from '@styles/Layout'; import styled from '@emotion/styled'; import 'dayjs/locale/ko'; -interface IProblem { - date: string; - problem: string; - difficulty: string; -} - -const problemRecords: IProblem[] = [ - { - date: '2024-05-20', - problem: '토마토', - difficulty: 'gold4', - }, - { - date: '2024-05-20', - problem: '사과', - difficulty: 'gold2', - }, - { - date: '2024-05-20', - problem: '감자', - difficulty: 'gold4', - }, - { - date: '2024-05-20', - problem: '감자', - difficulty: 'gold4', - }, - { - date: '2024-05-20', - problem: '감자', - difficulty: 'gold4', - }, - { - date: '2024-05-20', - problem: '감자', - difficulty: 'gold4', - }, -]; +// const problemRecords: IProblem[] = [ +// { +// solvedDate: '2024-05-20', +// commitUrl: 'https://github.com/gidskql6671', +// title: '토마토', +// rank: 'gold4', +// }, +// { +// solvedDate: '2024-05-20', +// commitUrl: 'https://github.com/gidskql6671', +// title: '사과', +// rank: 'gold2', +// }, +// { +// solvedDate: '2024-05-20', +// commitUrl: 'https://github.com/gidskql6671', +// title: '감자', +// rank: 'gold4', +// }, +// { +// solvedDate: '2024-05-20', +// commitUrl: 'https://github.com/gidskql6671', +// title: '감자', +// rank: 'gold4', +// }, +// { +// solvedDate: '2024-05-20', +// commitUrl: 'https://github.com/gidskql6671', +// title: '감자', +// rank: 'gold4', +// }, +// { +// solvedDate: '2024-05-20', +// commitUrl: 'https://github.com/gidskql6671', +// title: '감자', +// rank: 'gold4', +// }, +// ]; const FeedLayout = styled.div` margin-top: 62px; @@ -81,7 +88,13 @@ const ProfileWrapper = styled.div` `; const FeedPage = () => { + const { isAccessToken } = useTokenStore(); const { selectedDate, setSelectedDate } = useFeedStore(); + const { + data: problemData, + isPending: problemPending, + isError: problemError, + } = useProblem(); // eslint-disable-next-line @typescript-eslint/naming-convention const formatDay = (_locale: string | undefined, date: Date) => @@ -98,35 +111,58 @@ const FeedPage = () => { return ( - - - - - - - view === 'month' && - problemRecords.find( - (problem) => problem.date === dayjs(date).format('YYYY-MM-DD') - ) ? ( -
- ) : null - } - /> -
- {selectedDate && - problemRecords.find((problem) => problem.date === formattedDate) ? ( + {isAccessToken ? ( + + {' '} + + + + + + view === 'month' && + problemData && + problemData.length > 0 && + problemData.some( + (problem: IProblem) => + problem.solvedDate === dayjs(date).format('YYYY-MM-DD') + ) ? ( +
+ ) : null + } + /> +
+ {/* {selectedDate && + problemRecords.find( + (problem) => problem.solvedDate === formattedDate + ) ? ( ) : (
- )} - + )} */} + {selectedDate && + problemData && + !problemPending && + !problemError && ( + + )} + + ) : ( + + + 환영합니다! Guest님! 로그인 후 이용해주세요. + + + )} ); diff --git a/front/src/pages/search/SearchPage.tsx b/front/src/pages/search/SearchPage.tsx index 0535c9a..38eba76 100644 --- a/front/src/pages/search/SearchPage.tsx +++ b/front/src/pages/search/SearchPage.tsx @@ -2,7 +2,9 @@ import Text from '@components/typography/Text'; import SearchResult from '@pages/search/components/SearchResult'; -import { Layout, DisplayLayout } from '@styles/Layout'; +import { useTokenStore } from '@stores/useTokenStore'; + +import { Layout, DisplayLayout, LoginLayout } from '@styles/Layout'; import styled from '@emotion/styled'; @@ -15,14 +17,24 @@ const SearchLayout = styled(DisplayLayout)` `; const SearchPage = () => { + const { isAccessToken } = useTokenStore(); + return ( - - - 현재 그룹 목록 - - - + {isAccessToken ? ( + + + 현재 그룹 목록 + + + + ) : ( + + + 둘러보기 기능은 로그인 후 이용 가능합니다. + + + )} ); }; diff --git a/front/src/styles/Layout.ts b/front/src/styles/Layout.ts index 6d85a14..f56eb7c 100644 --- a/front/src/styles/Layout.ts +++ b/front/src/styles/Layout.ts @@ -13,3 +13,10 @@ export const DisplayLayout = styled.div` display: flex; justify-content: center; `; + +export const LoginLayout = styled.div` + display: flex; + justify-content: center; + align-items: center; + height: calc(100vh - 45px); +`; From 74597ac39a95c78b1667da91886164bba4e7f2cb Mon Sep 17 00:00:00 2001 From: KimKyuHoi Date: Wed, 29 May 2024 14:00:26 +0900 Subject: [PATCH 8/8] =?UTF-8?q?fix:=20Problem=20=EB=B0=8F=20Commit=20API?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/src/hooks/queries/feed/getProblems.ts | 6 +++--- front/src/pages/feed/FeedPage.tsx | 9 ++++----- front/src/pages/feed/components/Profile.tsx | 10 +++++----- front/src/services/feed/getProblems.ts | 9 +++++++-- front/src/services/feed/getUserCommit.ts | 8 +++++++- 5 files changed, 26 insertions(+), 16 deletions(-) diff --git a/front/src/hooks/queries/feed/getProblems.ts b/front/src/hooks/queries/feed/getProblems.ts index 7e27b84..7528407 100644 --- a/front/src/hooks/queries/feed/getProblems.ts +++ b/front/src/hooks/queries/feed/getProblems.ts @@ -2,10 +2,10 @@ import { getUserProblems } from '@services/feed/getProblems'; import { useQuery } from '@tanstack/react-query'; -export const useProblem = () => { +export const useProblem = (date: string | null) => { const { data, isPending, isError, error } = useQuery({ - queryKey: ['userProblems'], - queryFn: getUserProblems, + queryKey: ['userProblems', date], + queryFn: () => (date ? getUserProblems(date) : Promise.resolve([])), refetchOnMount: false, }); diff --git a/front/src/pages/feed/FeedPage.tsx b/front/src/pages/feed/FeedPage.tsx index b8981f7..f99b1b4 100644 --- a/front/src/pages/feed/FeedPage.tsx +++ b/front/src/pages/feed/FeedPage.tsx @@ -90,11 +90,14 @@ const ProfileWrapper = styled.div` const FeedPage = () => { const { isAccessToken } = useTokenStore(); const { selectedDate, setSelectedDate } = useFeedStore(); + const formattedDate = selectedDate + ? dayjs(selectedDate).format('YYYY-MM-DD') + : ''; const { data: problemData, isPending: problemPending, isError: problemError, - } = useProblem(); + } = useProblem(formattedDate); // eslint-disable-next-line @typescript-eslint/naming-convention const formatDay = (_locale: string | undefined, date: Date) => @@ -104,10 +107,6 @@ const FeedPage = () => { setSelectedDate(date); }; - const formattedDate = selectedDate - ? dayjs(selectedDate).format('YYYY-MM-DD') - : ''; - return ( diff --git a/front/src/pages/feed/components/Profile.tsx b/front/src/pages/feed/components/Profile.tsx index 6d22f53..c989fa7 100644 --- a/front/src/pages/feed/components/Profile.tsx +++ b/front/src/pages/feed/components/Profile.tsx @@ -2,11 +2,11 @@ // import axios from 'axios'; import Text from '@components/typography/Text'; +import { useCommits } from '@hooks/queries/feed/getUserCommitQuery'; import { useUserData } from '@hooks/queries/feed/getUserDataQuery'; import DefaultProfileImg from '@assets/HaedalProfile.png'; -// import { useCommits } from '@/hooks/queries/feed/getUserCommitQuery'; // import { useUserDataStore } from '@stores/useUserDataStore'; import styled from '@emotion/styled'; @@ -38,12 +38,12 @@ const Profile = () => { isPending: userPending, isError: userError, } = useUserData(); - // const { data: commit } = useCommits(); + const { data: commit } = useCommits(); const username = userData?.loginId || ''; const profileImg = userData?.profileUrl || DefaultProfileImg; - // const commitNum = commit?.commit || 0; + const commitNum = commit?.count || 0; - // console.log('commit', commit); + // console.log('commit', commit.count); // MSW Test CODE // const { // setUsername, @@ -104,7 +104,7 @@ const Profile = () => { {username}님 반갑습니다! - 오늘의 커밋 개수는 0개 입니다. + 오늘의 커밋 개수는 {commitNum}개 입니다. )} diff --git a/front/src/services/feed/getProblems.ts b/front/src/services/feed/getProblems.ts index b8602c8..97f8b3c 100644 --- a/front/src/services/feed/getProblems.ts +++ b/front/src/services/feed/getProblems.ts @@ -2,9 +2,14 @@ import { BASE_URI } from '@constants/URI'; import { instance } from '@services/API_JWT'; -export const getUserProblems = async () => { +export const getUserProblems = async (date: string) => { try { - const response = await instance.get(`${BASE_URI}/problems`); + const response = await instance.get(`${BASE_URI}/problems`, { + params: { + type: 'DAY', + date: date, + }, + }); return response.data; } catch (error) { console.error('Error fetching UserData:', error); diff --git a/front/src/services/feed/getUserCommit.ts b/front/src/services/feed/getUserCommit.ts index 7cb2a09..5555a9c 100644 --- a/front/src/services/feed/getUserCommit.ts +++ b/front/src/services/feed/getUserCommit.ts @@ -1,10 +1,16 @@ +import dayjs from 'dayjs'; + import { BASE_URI } from '@constants/URI'; import { instance } from '@services/API_JWT'; export const getUserCommit = async () => { + const currentDate = dayjs().format('YYYY-MM-DD'); // 현재 날짜를 yyyy-mm-dd 형식으로 추출 + try { - const response = await instance.get(`${BASE_URI}/problems/count`); + const response = await instance.get( + `${BASE_URI}/problems/count?date=${currentDate}` + ); return response.data; } catch (error) { console.error('Error fetching UserData:', error);