-
Notifications
You must be signed in to change notification settings - Fork 4
Feat/refactor/meeting list/DEVING-57 #53
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
Changes from 5 commits
da5756b
8acbc29
3d80dfe
1558067
a2097cf
b653c3c
5695a3c
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,28 +1,71 @@ | ||
| import FloatingButtonGroup from '@/components/common/FloatingButtonGroup'; | ||
| import { MEETING_QUERY_KEYS } from '@/hooks/queries/useMeetingQueries'; | ||
| import { translateCategoryNameToKor } from '@/util/searchFilter'; | ||
| import { | ||
| HydrationBoundary, | ||
| QueryClient, | ||
| dehydrate, | ||
| } from '@tanstack/react-query'; | ||
| import { MEETING_TYPES } from 'constants/meeting-form/meetingConstants'; | ||
| import { notFound } from 'next/navigation'; | ||
| import { getMeetings, getTopMeetings } from 'service/api/meeting'; | ||
| import { Paginated, SearchMeeting } from 'types/meeting'; | ||
|
|
||
| import MeetingList from '../_features/MeetingList'; | ||
| import RecommendMeeting from '../_features/RecommendMeeting'; | ||
|
|
||
| const ALLOWED_CATEGORIES = ['mogakco', 'study', 'side-project', 'hobby']; // ํ์ฉ๋ ์นดํ ๊ณ ๋ฆฌ ๋ฆฌ์คํธ | ||
|
|
||
| // ์ ์ ๊ฒฝ๋ก ์ฌ์ ์์ฑ | ||
| export async function generateStaticParams() { | ||
| return ALLOWED_CATEGORIES.map((category) => ({ category })); | ||
| return MEETING_TYPES.map((category) => category.id); | ||
| } | ||
|
|
||
| function MeetingListPage({ params }: { params: { category: string } }) { | ||
| async function MeetingListPage({ params }: { params: { category: string } }) { | ||
| const { category } = params; | ||
|
|
||
| const queryClient = new QueryClient(); | ||
|
|
||
| const initialSearchQueryObj = { | ||
| keyword: '', | ||
| skillArray: [], | ||
| sortField: 'NEW', | ||
| lastMeetingId: 0, | ||
| size: 4, | ||
| }; | ||
|
|
||
| await queryClient.prefetchQuery({ | ||
| queryKey: MEETING_QUERY_KEYS.topMeetings( | ||
| translateCategoryNameToKor(category), | ||
| ), | ||
| queryFn: () => getTopMeetings(translateCategoryNameToKor(category)), | ||
| }); | ||
|
|
||
| await queryClient.prefetchInfiniteQuery({ | ||
| queryKey: MEETING_QUERY_KEYS.meetings( | ||
| translateCategoryNameToKor(category), | ||
| initialSearchQueryObj, | ||
| ), | ||
| queryFn: () => | ||
| getMeetings( | ||
| 0, | ||
| translateCategoryNameToKor(category), | ||
| initialSearchQueryObj, | ||
| ), | ||
| getNextPageParam: (lastPage: Paginated<SearchMeeting>) => | ||
| lastPage.nextCursor ?? false, | ||
| initialPageParam: 1, | ||
| }); | ||
|
|
||
|
Contributor
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. ์๋ถ๋ถ promise.all ๋ก ๋ฌถ์ด์ ๋ณ๋ ฌ์ฒ๋ฆฌ ํด๋ณด๋๊ฒ๋ ์ข์ ๊ฒ ๊ฐ์ต๋๋น
Contributor
Author
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. promise.all ๋ก ๋ฌถ์ด์ ์ฒ๋ฆฌ ํ ๊ฒฝ์ฐ ํ๋๋ผ๋ ์คํจํ๋ฉด ์ ์ฒด๊ฐ reject ๋์ด์ ์ ์ฒด ์๋ฌ ์ฒ๋ฆฌ๊ฐ ๋ฐ์ํ๊ฒ ๋๋๋ฐ,
Contributor
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. ์คํธ ์ข์ต๋๋ค ๊ฐ์ฌํฉ๋๋น |
||
| // ํ์ฉ๋์ง ์์ category๊ฐ ๋ค์ด์ค๋ฉด 404 ํ์ด์ง๋ก ์ด๋ | ||
| if (!ALLOWED_CATEGORIES.includes(category)) { | ||
| if (!MEETING_TYPES.map((category) => category.id).includes(category)) { | ||
| notFound(); | ||
| } | ||
| return ( | ||
| <div className="mb-[130px] mt-[88px]"> | ||
| <FloatingButtonGroup /> | ||
| <RecommendMeeting /> | ||
| <MeetingList /> | ||
| <HydrationBoundary state={dehydrate(queryClient)}> | ||
| <RecommendMeeting /> | ||
| <MeetingList /> | ||
| </HydrationBoundary> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
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.
pageParam์ ๋ฐ๋ก ์ฐ์ง ์๊ณ initialPageParam์ 1๋ก ์์ํ์ ์ด์ ๊ฐ ์์ผ์ค๊น์ฉ?
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.
์ ์๋จ! ์๋ชป๋ค์ด๊ฐ๊ฑฐ ๊ฐ์์ 0์ผ๋ก ์์ ํ์ต๋๋น