From 0f79204534f7cfda2f94f2b1ae9557b97c99aed1 Mon Sep 17 00:00:00 2001 From: KimKyuHoi Date: Wed, 29 May 2024 20:12:26 +0900 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20=EB=8B=AC=EB=B3=84=20=EB=82=A0?= =?UTF-8?q?=EC=A7=9C=20=ED=91=9C=ED=98=84=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/hooks/queries/feed/getProblemMonth.ts | 14 ++++++++++++++ front/src/pages/feed/FeedPage.tsx | 12 +++++++++--- front/src/services/feed/getProblemMonth.ts | 18 ++++++++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 front/src/hooks/queries/feed/getProblemMonth.ts create mode 100644 front/src/services/feed/getProblemMonth.ts diff --git a/front/src/hooks/queries/feed/getProblemMonth.ts b/front/src/hooks/queries/feed/getProblemMonth.ts new file mode 100644 index 0000000..b894309 --- /dev/null +++ b/front/src/hooks/queries/feed/getProblemMonth.ts @@ -0,0 +1,14 @@ +import { getUserProblemMonth } from '@services/feed/getProblemMonth'; + +import { useQuery } from '@tanstack/react-query'; + +export const useProblemMonth = (yearMonth: string | null) => { + const { data, isPending, isError, error } = useQuery({ + queryKey: ['userProblemsMonth', yearMonth], + queryFn: () => + yearMonth ? getUserProblemMonth(yearMonth) : Promise.resolve([]), + refetchOnMount: false, + }); + + return { data, isPending, isError, error }; +}; diff --git a/front/src/pages/feed/FeedPage.tsx b/front/src/pages/feed/FeedPage.tsx index f99b1b4..f5f7b9e 100644 --- a/front/src/pages/feed/FeedPage.tsx +++ b/front/src/pages/feed/FeedPage.tsx @@ -17,6 +17,7 @@ import { IProblem } from '@interfaces/ProblemInterface'; import { Layout, DisplayLayout, LoginLayout } from '@styles/Layout'; +import { useProblemMonth } from '@/hooks/queries/feed/getProblemMonth'; import styled from '@emotion/styled'; import 'dayjs/locale/ko'; @@ -93,11 +94,16 @@ const FeedPage = () => { const formattedDate = selectedDate ? dayjs(selectedDate).format('YYYY-MM-DD') : ''; + + const formattedMonth = selectedDate + ? dayjs(selectedDate).format('YYYY-MM') + : ''; const { data: problemData, isPending: problemPending, isError: problemError, } = useProblem(formattedDate); + const { data: problemDataMonth } = useProblemMonth(formattedMonth); // eslint-disable-next-line @typescript-eslint/naming-convention const formatDay = (_locale: string | undefined, date: Date) => @@ -123,9 +129,9 @@ const FeedPage = () => { onClickDay={handleDateClick} tileContent={({ date, view }) => view === 'month' && - problemData && - problemData.length > 0 && - problemData.some( + problemDataMonth && + problemDataMonth.length > 0 && + problemDataMonth.some( (problem: IProblem) => problem.solvedDate === dayjs(date).format('YYYY-MM-DD') ) ? ( diff --git a/front/src/services/feed/getProblemMonth.ts b/front/src/services/feed/getProblemMonth.ts new file mode 100644 index 0000000..4d9c34e --- /dev/null +++ b/front/src/services/feed/getProblemMonth.ts @@ -0,0 +1,18 @@ +import { BASE_URI } from '@constants/URI'; + +import { instance } from '@services/API_JWT'; + +export const getUserProblemMonth = async (yearMonth: string) => { + try { + const response = await instance.get(`${BASE_URI}/problems`, { + params: { + type: 'MONTH', + yearMonth: yearMonth, + }, + }); + return response.data; + } catch (error) { + console.error('Error fetching UserData:', error); + throw error; + } +}; From 385754cf36f539a2179a5619ea5d2ebf02aa9d24 Mon Sep 17 00:00:00 2001 From: KimKyuHoi Date: Wed, 29 May 2024 20:45:41 +0900 Subject: [PATCH 2/5] =?UTF-8?q?fix:=20=ED=94=BC=EB=93=9C=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=EC=97=90=EC=84=9C=20=EB=A7=A8=20=EC=B2=98?= =?UTF-8?q?=EC=9D=8C=20=ED=99=94=EB=A9=B4=EC=97=90=EC=84=9C=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=EB=A5=BC=20=EB=B6=88=EB=9F=AC=EC=98=AC?= =?UTF-8?q?=EB=95=8C=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EB=9C=A8=EA=B8=B0=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/src/hooks/queries/Http.ts | 3 -- .../src/hooks/queries/feed/getProblemMonth.ts | 4 ++- front/src/hooks/queries/feed/getProblems.ts | 4 ++- .../hooks/queries/feed/getUserCommitQuery.ts | 2 ++ .../hooks/queries/feed/getUserDataQuery.ts | 2 ++ .../hooks/queries/group/getMyGroupQuery.ts | 1 + .../hooks/queries/search/getGroupsQuery.ts | 2 ++ front/src/pages/feed/FeedPage.tsx | 28 ++++++------------- 8 files changed, 21 insertions(+), 25 deletions(-) diff --git a/front/src/hooks/queries/Http.ts b/front/src/hooks/queries/Http.ts index f90de6e..9215c0e 100644 --- a/front/src/hooks/queries/Http.ts +++ b/front/src/hooks/queries/Http.ts @@ -7,9 +7,6 @@ export const queryClient = new QueryClient({ queries: { retry: 0, staleTime: 1000 * 60 * 5, - refetchOnWindowFocus: false, - refetchOnMount: false, - refetchOnReconnect: false, }, }, queryCache: new QueryCache({ diff --git a/front/src/hooks/queries/feed/getProblemMonth.ts b/front/src/hooks/queries/feed/getProblemMonth.ts index b894309..e7bff9d 100644 --- a/front/src/hooks/queries/feed/getProblemMonth.ts +++ b/front/src/hooks/queries/feed/getProblemMonth.ts @@ -7,7 +7,9 @@ export const useProblemMonth = (yearMonth: string | null) => { queryKey: ['userProblemsMonth', yearMonth], queryFn: () => yearMonth ? getUserProblemMonth(yearMonth) : Promise.resolve([]), - refetchOnMount: false, + refetchOnWindowFocus: false, + refetchOnMount: true, + refetchOnReconnect: false, }); return { data, isPending, isError, error }; diff --git a/front/src/hooks/queries/feed/getProblems.ts b/front/src/hooks/queries/feed/getProblems.ts index 7528407..a61dd05 100644 --- a/front/src/hooks/queries/feed/getProblems.ts +++ b/front/src/hooks/queries/feed/getProblems.ts @@ -6,7 +6,9 @@ export const useProblem = (date: string | null) => { const { data, isPending, isError, error } = useQuery({ queryKey: ['userProblems', date], queryFn: () => (date ? getUserProblems(date) : Promise.resolve([])), - refetchOnMount: false, + refetchOnMount: true, + refetchOnWindowFocus: false, + refetchOnReconnect: false, }); return { data, isPending, isError, error }; diff --git a/front/src/hooks/queries/feed/getUserCommitQuery.ts b/front/src/hooks/queries/feed/getUserCommitQuery.ts index c8f9b5a..56a0989 100644 --- a/front/src/hooks/queries/feed/getUserCommitQuery.ts +++ b/front/src/hooks/queries/feed/getUserCommitQuery.ts @@ -6,7 +6,9 @@ export const useCommits = () => { const { data, isPending, isError, error } = useQuery({ queryKey: ['user_commit'], queryFn: getUserCommit, + refetchOnWindowFocus: false, refetchOnMount: false, + refetchOnReconnect: false, }); return { data, isPending, isError, error }; diff --git a/front/src/hooks/queries/feed/getUserDataQuery.ts b/front/src/hooks/queries/feed/getUserDataQuery.ts index b810f44..83bd264 100644 --- a/front/src/hooks/queries/feed/getUserDataQuery.ts +++ b/front/src/hooks/queries/feed/getUserDataQuery.ts @@ -6,7 +6,9 @@ export const useUserData = () => { const { data, isPending, isError, error } = useQuery({ queryKey: ['users'], queryFn: getUserData, + refetchOnWindowFocus: false, refetchOnMount: false, + refetchOnReconnect: false, }); return { data, isPending, isError, error }; diff --git a/front/src/hooks/queries/group/getMyGroupQuery.ts b/front/src/hooks/queries/group/getMyGroupQuery.ts index 84cddf8..087154a 100644 --- a/front/src/hooks/queries/group/getMyGroupQuery.ts +++ b/front/src/hooks/queries/group/getMyGroupQuery.ts @@ -8,6 +8,7 @@ export const useMyGroupData = () => { queryFn: getMyGroup, refetchOnMount: false, refetchOnWindowFocus: true, + refetchOnReconnect: false, }); return { data, isPending, isError, error, refetch }; diff --git a/front/src/hooks/queries/search/getGroupsQuery.ts b/front/src/hooks/queries/search/getGroupsQuery.ts index 7022531..234346e 100644 --- a/front/src/hooks/queries/search/getGroupsQuery.ts +++ b/front/src/hooks/queries/search/getGroupsQuery.ts @@ -6,7 +6,9 @@ export const useGroups = () => { const { data, isPending, isError, error, refetch } = useQuery({ queryKey: ['users-groups'], queryFn: getGroups, + refetchOnWindowFocus: false, refetchOnMount: false, + refetchOnReconnect: false, }); return { data, isPending, isError, error, refetch }; diff --git a/front/src/pages/feed/FeedPage.tsx b/front/src/pages/feed/FeedPage.tsx index f5f7b9e..32baf0b 100644 --- a/front/src/pages/feed/FeedPage.tsx +++ b/front/src/pages/feed/FeedPage.tsx @@ -140,26 +140,14 @@ const FeedPage = () => { } /> - {/* {selectedDate && - problemRecords.find( - (problem) => problem.solvedDate === formattedDate - ) ? ( - - ) : ( -
- )} */} - {selectedDate && - problemData && - !problemPending && - !problemError && ( - - )} + {selectedDate && problemData && !problemPending && !problemError ? ( + + ) : ( +
+ )} ) : ( From 85ecc8695974f95541c2b2c996bd6d73c3f5e351 Mon Sep 17 00:00:00 2001 From: KimKyuHoi Date: Thu, 30 May 2024 00:31:08 +0900 Subject: [PATCH 3/5] =?UTF-8?q?refac:=20=EC=BD=94=EB=93=9C=20rebase?= =?UTF-8?q?=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/src/hooks/queries/Http.ts | 3 +++ front/src/hooks/queries/feed/getProblemMonth.ts | 7 ++----- front/src/hooks/queries/feed/getProblems.ts | 7 ++----- front/src/hooks/queries/feed/getUserCommitQuery.ts | 3 --- front/src/hooks/queries/feed/getUserDataQuery.ts | 3 --- front/src/hooks/queries/group/getMyGroupQuery.ts | 3 --- front/src/hooks/queries/search/getGroupsQuery.ts | 3 --- 7 files changed, 7 insertions(+), 22 deletions(-) diff --git a/front/src/hooks/queries/Http.ts b/front/src/hooks/queries/Http.ts index 9215c0e..f1f065f 100644 --- a/front/src/hooks/queries/Http.ts +++ b/front/src/hooks/queries/Http.ts @@ -7,6 +7,9 @@ export const queryClient = new QueryClient({ queries: { retry: 0, staleTime: 1000 * 60 * 5, + refetchOnMount: false, + refetchOnWindowFocus: false, + refetchOnReconnect: false, }, }, queryCache: new QueryCache({ diff --git a/front/src/hooks/queries/feed/getProblemMonth.ts b/front/src/hooks/queries/feed/getProblemMonth.ts index e7bff9d..9edea2f 100644 --- a/front/src/hooks/queries/feed/getProblemMonth.ts +++ b/front/src/hooks/queries/feed/getProblemMonth.ts @@ -3,14 +3,11 @@ import { getUserProblemMonth } from '@services/feed/getProblemMonth'; import { useQuery } from '@tanstack/react-query'; export const useProblemMonth = (yearMonth: string | null) => { - const { data, isPending, isError, error } = useQuery({ + const { data, isPending, isError, error, refetch } = useQuery({ queryKey: ['userProblemsMonth', yearMonth], queryFn: () => yearMonth ? getUserProblemMonth(yearMonth) : Promise.resolve([]), - refetchOnWindowFocus: false, - refetchOnMount: true, - refetchOnReconnect: false, }); - return { data, isPending, isError, error }; + return { data, isPending, isError, error, refetch }; }; diff --git a/front/src/hooks/queries/feed/getProblems.ts b/front/src/hooks/queries/feed/getProblems.ts index a61dd05..ae0922e 100644 --- a/front/src/hooks/queries/feed/getProblems.ts +++ b/front/src/hooks/queries/feed/getProblems.ts @@ -3,13 +3,10 @@ import { getUserProblems } from '@services/feed/getProblems'; import { useQuery } from '@tanstack/react-query'; export const useProblem = (date: string | null) => { - const { data, isPending, isError, error } = useQuery({ + const { data, isPending, isError, error, refetch } = useQuery({ queryKey: ['userProblems', date], queryFn: () => (date ? getUserProblems(date) : Promise.resolve([])), - refetchOnMount: true, - refetchOnWindowFocus: false, - refetchOnReconnect: false, }); - return { data, isPending, isError, error }; + return { data, isPending, isError, error, refetch }; }; diff --git a/front/src/hooks/queries/feed/getUserCommitQuery.ts b/front/src/hooks/queries/feed/getUserCommitQuery.ts index 56a0989..89782cb 100644 --- a/front/src/hooks/queries/feed/getUserCommitQuery.ts +++ b/front/src/hooks/queries/feed/getUserCommitQuery.ts @@ -6,9 +6,6 @@ export const useCommits = () => { const { data, isPending, isError, error } = useQuery({ queryKey: ['user_commit'], queryFn: getUserCommit, - refetchOnWindowFocus: false, - refetchOnMount: false, - refetchOnReconnect: false, }); return { data, isPending, isError, error }; diff --git a/front/src/hooks/queries/feed/getUserDataQuery.ts b/front/src/hooks/queries/feed/getUserDataQuery.ts index 83bd264..53bf2e7 100644 --- a/front/src/hooks/queries/feed/getUserDataQuery.ts +++ b/front/src/hooks/queries/feed/getUserDataQuery.ts @@ -6,9 +6,6 @@ export const useUserData = () => { const { data, isPending, isError, error } = useQuery({ queryKey: ['users'], queryFn: getUserData, - refetchOnWindowFocus: false, - refetchOnMount: false, - refetchOnReconnect: false, }); return { data, isPending, isError, error }; diff --git a/front/src/hooks/queries/group/getMyGroupQuery.ts b/front/src/hooks/queries/group/getMyGroupQuery.ts index 087154a..426e3a0 100644 --- a/front/src/hooks/queries/group/getMyGroupQuery.ts +++ b/front/src/hooks/queries/group/getMyGroupQuery.ts @@ -6,9 +6,6 @@ export const useMyGroupData = () => { const { data, isPending, isError, error, refetch } = useQuery({ queryKey: ['users-group'], queryFn: getMyGroup, - refetchOnMount: false, - refetchOnWindowFocus: true, - refetchOnReconnect: false, }); return { data, isPending, isError, error, refetch }; diff --git a/front/src/hooks/queries/search/getGroupsQuery.ts b/front/src/hooks/queries/search/getGroupsQuery.ts index 234346e..24ca231 100644 --- a/front/src/hooks/queries/search/getGroupsQuery.ts +++ b/front/src/hooks/queries/search/getGroupsQuery.ts @@ -6,9 +6,6 @@ export const useGroups = () => { const { data, isPending, isError, error, refetch } = useQuery({ queryKey: ['users-groups'], queryFn: getGroups, - refetchOnWindowFocus: false, - refetchOnMount: false, - refetchOnReconnect: false, }); return { data, isPending, isError, error, refetch }; From 60cc69d8b428ec2ce77c3352d9be80a5ceb00c14 Mon Sep 17 00:00:00 2001 From: KimKyuHoi Date: Thu, 30 May 2024 00:31:22 +0900 Subject: [PATCH 4/5] =?UTF-8?q?fix:=20=EC=B2=AB=20=ED=99=94=EB=A9=B4?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=ED=95=B4=EB=8B=B9=20=EB=AC=B8=EC=A0=9C=20?= =?UTF-8?q?=ED=91=9C=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/src/pages/feed/FeedPage.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/front/src/pages/feed/FeedPage.tsx b/front/src/pages/feed/FeedPage.tsx index 32baf0b..c369dfb 100644 --- a/front/src/pages/feed/FeedPage.tsx +++ b/front/src/pages/feed/FeedPage.tsx @@ -97,7 +97,7 @@ const FeedPage = () => { const formattedMonth = selectedDate ? dayjs(selectedDate).format('YYYY-MM') - : ''; + : dayjs().format('YYYY-MM'); const { data: problemData, isPending: problemPending, @@ -105,7 +105,6 @@ const FeedPage = () => { } = useProblem(formattedDate); const { data: problemDataMonth } = useProblemMonth(formattedMonth); - // eslint-disable-next-line @typescript-eslint/naming-convention const formatDay = (_locale: string | undefined, date: Date) => dayjs(date).format('D'); From 561e898f6fd619ebf187e7b7f1629887bf4d965a Mon Sep 17 00:00:00 2001 From: KimKyuHoi Date: Thu, 30 May 2024 00:31:59 +0900 Subject: [PATCH 5/5] =?UTF-8?q?feat:=20=EB=91=98=EB=9F=AC=EB=B3=B4?= =?UTF-8?q?=EA=B8=B0=20=ED=8E=98=EC=9D=B4=EC=A7=80=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EB=B3=B8=EC=9D=B8=20=EC=95=84=EB=8B=8C=20=ED=8C=80=EB=A7=8C=20?= =?UTF-8?q?=EB=B3=B4=EC=9D=B4=EB=8F=84=EB=A1=9D=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/src/interfaces/GroupInterface.ts | 1 + .../src/pages/group/components/GroupLists.tsx | 24 ++++----- .../pages/search/components/SearchResult.tsx | 51 ++++++++++++++++--- 3 files changed, 56 insertions(+), 20 deletions(-) diff --git a/front/src/interfaces/GroupInterface.ts b/front/src/interfaces/GroupInterface.ts index 54c8d32..a0d9405 100644 --- a/front/src/interfaces/GroupInterface.ts +++ b/front/src/interfaces/GroupInterface.ts @@ -2,6 +2,7 @@ export interface IGroupProps { id: number; name: string; isPrivate: boolean; + isMember: boolean; } export interface ICreateGroupModalProps { diff --git a/front/src/pages/group/components/GroupLists.tsx b/front/src/pages/group/components/GroupLists.tsx index 52d3dd1..3e0697f 100644 --- a/front/src/pages/group/components/GroupLists.tsx +++ b/front/src/pages/group/components/GroupLists.tsx @@ -9,18 +9,18 @@ import { IGroupProps } from '@interfaces/GroupInterface'; import styled from '@emotion/styled'; -const MyGroupLists = [ - { - id: 1, - name: '해달 파이팅', - isPrivate: false, - }, - { - id: 2, - name: '해달 고고', - isPrivate: false, - }, -]; +// const MyGroupLists = [ +// { +// id: 1, +// name: '해달 파이팅', +// isPrivate: false, +// }, +// { +// id: 2, +// name: '해달 고고', +// isPrivate: false, +// }, +// ]; const GroupContainer = styled.div` padding: 20px; diff --git a/front/src/pages/search/components/SearchResult.tsx b/front/src/pages/search/components/SearchResult.tsx index b7dc7d7..720830d 100644 --- a/front/src/pages/search/components/SearchResult.tsx +++ b/front/src/pages/search/components/SearchResult.tsx @@ -42,6 +42,26 @@ const InputResultLayout = styled.div` padding: 0.5rem 1rem; `; +const GroupType = styled.p` + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + margin: 5px 0 0; + font-size: 14px; + color: var(--color-white); + width: 60px; + height: 20px; + border-radius: 12px; + background-color: var(--color-red); + font-size: var(--size-xs); +`; + +const GroupTypeLayout = styled.div` + display: flex; + flex-direction: column; +`; + const SearchResult = () => { const { data, isPending, isError, error } = useGroups(); @@ -61,18 +81,33 @@ const SearchResult = () => { return 검색 결과가 없습니다.; } + const filteredGroups = data.filter((group: IGroupProps) => !group.isMember); + const onClickNav = () => {}; return ( - {data.map((group: IGroupProps) => ( - - - {group.name} - - 참여하기 - - ))} + {filteredGroups.length === 0 ? ( + + 조건에 맞는 검색 결과가 없습니다. + + ) : ( + filteredGroups.map((group: IGroupProps) => ( + + + + {group.name} + + {group.isPrivate ? 'Private' : 'Public'} + + 참여하기 + + )) + )} ); };