-
Notifications
You must be signed in to change notification settings - Fork 2
Feat: 자유게시판 리스트 SSR 프리패치 구현 및 스타일 개선 #82
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8aa8543
fix: 미들웨어에 devtools 로그가 뜨는 문제 제거
DreamPaste 4a150c8
feat: 자유게시판 리스트를 프리패치하도록 개선
DreamPaste 835a3bf
fix: 리스트 gap 충돌 문제 해결
DreamPaste dc5f433
fix: SortHeader 스타일 개선
DreamPaste 3fe6c0b
feat: formatCount가 한글도 지원하도록 개선
DreamPaste 7c86397
feat: 자유게시판 카드에 formatCount 적용
DreamPaste 047fb21
fix: 자유게시판 카드에 썸네일 이미지 제공
DreamPaste 3311fbc
fix: 카드 평균 높이를 정확하게 계산하여, CommunityPostList의 Gap 리사이징 이슈 해결
DreamPaste d53a980
Merge branch 'dev' into feat/SOS-43-freeboard-SSR
DreamPaste File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
apps/web/src/app/main/community/freeboard/ClientPage.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| 'use client'; | ||
|
|
||
| import React, { useState } from 'react'; | ||
| import { useInfiniteQuery } from '@tanstack/react-query'; | ||
| import { PillChipsTab } from '@/components/tabs/PillChipsTab'; | ||
| import { CATEGORIES, Category } from '../constants/categories'; | ||
| import { SortHeader } from '../components/SortHeader'; | ||
| import { SortValue } from '@/types/options.types'; | ||
| import { SORT_OPTIONS } from '../constants/sortOptions'; | ||
| import FloatingButton from '@/components/buttons/FloatingButton'; | ||
| import { FreeBoardCard } from '../components/FreeboardCard'; | ||
| import CommunityPostList from '../components/CommunityPostList'; | ||
| import { FreeboardSummary } from '@/generated/api/models'; | ||
| import { | ||
| getFreeboardPostsByCursor, | ||
| getGetFreeboardPostsByCursorQueryKey, | ||
| } from '@/generated/api/endpoints/freeboard/freeboard'; | ||
|
|
||
| /** | ||
| * 자유 게시판 클라이언트 메인 페이지 | ||
| * | ||
| * @description | ||
| * - 카테고리별 게시글 목록을 보여주는 페이지 | ||
| * - 무한스크롤 기능 포함 | ||
| * - 카테고리 및 정렬 옵션 선택 가능 | ||
| */ | ||
|
|
||
| export default function FreeboardClientPage() { | ||
| const [category, setCategory] = useState<Category | null>(null); | ||
| const [sortOption, setSortOption] = useState<SortValue>('LATEST'); | ||
|
|
||
| // 무한스크롤 데이터 페칭 | ||
| const { | ||
| data, | ||
| fetchNextPage, | ||
| hasNextPage, | ||
| isLoading, | ||
| isFetchingNextPage, | ||
| error, | ||
| refetch, | ||
| } = useInfiniteQuery({ | ||
| queryKey: getGetFreeboardPostsByCursorQueryKey({ | ||
| // queryKey 생성 함수 사용 | ||
| category: category ?? undefined, // null일 경우 undefined로 변환 | ||
| sort: sortOption, | ||
| }), | ||
| queryFn: ({ pageParam, signal }) => | ||
| getFreeboardPostsByCursor( | ||
| { | ||
| category: category ?? undefined, | ||
| sort: sortOption, | ||
| cursor: pageParam, | ||
| size: 10, | ||
| }, | ||
| signal, | ||
| ), | ||
| initialPageParam: undefined as string | undefined, | ||
| getNextPageParam: (lastPage) => { | ||
| return lastPage.hasNext ? lastPage.nextCursor : undefined; | ||
| }, | ||
| }); | ||
|
|
||
| // 모든 페이지의 게시글을 하나의 배열로 합치기 | ||
| const allFreeboardPosts: FreeboardSummary[] = | ||
| data?.pages.flatMap((page) => page.posts ?? []) ?? []; | ||
| // 총 게시글 개수 | ||
| const totalCount = data?.pages[0]?.totalCount ?? 0; | ||
|
|
||
| return ( | ||
| <main className="w-full h-full flex flex-col"> | ||
| <PillChipsTab<Category> | ||
| chips={CATEGORIES} | ||
| activeValue={category} | ||
| onChange={setCategory} | ||
| showAll | ||
| ariaLabel="카테고리 선택 필터" | ||
| /> | ||
| <SortHeader | ||
| totalCount={totalCount} | ||
| sortOptions={SORT_OPTIONS} | ||
| currentValue={sortOption} | ||
| onFilterChange={setSortOption} | ||
| className="px-5" | ||
| /> | ||
| <CommunityPostList<FreeboardSummary> | ||
| items={allFreeboardPosts} | ||
| hasNextPage={hasNextPage || false} | ||
| fetchNextPage={fetchNextPage} | ||
| isFetchingNextPage={isFetchingNextPage} | ||
| initialLoading={isLoading} | ||
| error={error} | ||
| onRetry={() => refetch()} | ||
| getItemKey={(post, index) => post.postId ?? `post-${index}`} | ||
| renderItem={(post) => ( | ||
| <FreeBoardCard post={post} isChip={true} /> | ||
| )} | ||
| storageKey="freeboard-post-list-scroll" | ||
| /> | ||
| <FloatingButton categories={CATEGORIES} /> | ||
| </main> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,101 +1,46 @@ | ||
| 'use client'; | ||
| import React, { useState } from 'react'; | ||
| import { useInfiniteQuery } from '@tanstack/react-query'; | ||
| import { PillChipsTab } from '@/components/tabs/PillChipsTab'; | ||
| import { CATEGORIES, Category } from '../constants/categories'; | ||
| import { SortHeader } from '../components/SortHeader'; | ||
| import { SortValue } from '@/types/options.types'; | ||
| import { SORT_OPTIONS } from '../constants/sortOptions'; | ||
| import FloatingButton from '@/components/buttons/FloatingButton'; | ||
| import { FreeBoardCard } from '../components/FreeboardCard'; | ||
| import CommunityPostList from '../components/CommunityPostList'; | ||
|
|
||
| import { FreeboardSummary } from '@/generated/api/models'; | ||
| import { | ||
| HydrationBoundary, | ||
| QueryClient, | ||
| dehydrate, | ||
| } from '@tanstack/react-query'; | ||
| import { | ||
| getFreeboardPostsByCursor, | ||
| getGetFreeboardPostsByCursorQueryKey, | ||
| } from '@/generated/api/endpoints/freeboard/freeboard'; | ||
| import ClientPage from './ClientPage'; | ||
|
|
||
| /** | ||
| * 자유 게시판 메인 페이지 | ||
| * 자유 게시판 메인 페이지 (서버 컴포넌트) | ||
| * | ||
| * @description | ||
| * - 카테고리별 게시글 목록을 보여주는 페이지 | ||
| * - 무한스크롤 기능 포함 | ||
| * - 카테고리 및 정렬 옵션 선택 가능 | ||
| * - 전체 카테고리 | ||
| * - 최신순 정렬 | ||
| * - 10개 게시글 프리패치 | ||
| */ | ||
|
|
||
| export default function FreeboardPage() { | ||
| const [category, setCategory] = useState<Category | null>(null); | ||
| const [sortOption, setSortOption] = useState<SortValue>('LATEST'); | ||
| export default async function FreeboardPage() { | ||
| const queryClient = new QueryClient(); | ||
|
|
||
| // 무한스크롤 데이터 페칭 | ||
| const { | ||
| data, | ||
| fetchNextPage, | ||
| hasNextPage, | ||
| isLoading, | ||
| isFetchingNextPage, | ||
| error, | ||
| refetch, | ||
| } = useInfiniteQuery({ | ||
| await queryClient.prefetchInfiniteQuery({ | ||
| queryKey: getGetFreeboardPostsByCursorQueryKey({ | ||
| // queryKey 생성 함수 사용 | ||
| category: category ?? undefined, // null일 경우 undefined로 변환 | ||
| sort: sortOption, | ||
| category: undefined, | ||
| sort: 'LATEST', | ||
| }), | ||
| queryFn: ({ pageParam, signal }) => | ||
| queryFn: async ({ signal }) => | ||
| getFreeboardPostsByCursor( | ||
| { | ||
| category: category ?? undefined, | ||
| sort: sortOption, | ||
| cursor: pageParam, | ||
| size: 10, | ||
| }, | ||
| { category: undefined, sort: 'LATEST', size: 10 }, | ||
| signal, | ||
| ), | ||
| initialPageParam: undefined as string | undefined, | ||
| getNextPageParam: (lastPage) => { | ||
| return lastPage.hasNext ? lastPage.nextCursor : undefined; | ||
| }, | ||
| pages: 1, | ||
| }); | ||
|
|
||
| // 모든 페이지의 게시글을 하나의 배열로 합치기 | ||
| const allFreeboardPosts: FreeboardSummary[] = | ||
| data?.pages.flatMap((page) => page.posts ?? []) ?? []; | ||
| // 총 게시글 개수 | ||
| const totalCount = data?.pages[0]?.totalCount ?? 0; | ||
|
|
||
| return ( | ||
| <main className="w-full h-full flex flex-col"> | ||
| <PillChipsTab<Category> | ||
| chips={CATEGORIES} | ||
| activeValue={category} | ||
| onChange={setCategory} | ||
| showAll | ||
| ariaLabel="카테고리 선택 필터" | ||
| /> | ||
| <SortHeader | ||
| totalCount={totalCount} | ||
| sortOptions={SORT_OPTIONS} | ||
| currentValue={sortOption} | ||
| onFilterChange={setSortOption} | ||
| /> | ||
| <CommunityPostList<FreeboardSummary> | ||
| items={allFreeboardPosts} | ||
| hasNextPage={hasNextPage || false} | ||
| fetchNextPage={fetchNextPage} | ||
| isFetchingNextPage={isFetchingNextPage} | ||
| initialLoading={isLoading} | ||
| error={error} | ||
| onRetry={() => refetch()} | ||
| getItemKey={(post, index) => post.postId ?? `post-${index}`} | ||
| renderItem={(post) => ( | ||
| <FreeBoardCard post={post} isChip={true} /> | ||
| )} | ||
| storageKey="freeboard-post-list-scroll" | ||
| /> | ||
| <FloatingButton categories={CATEGORIES} /> | ||
| </main> | ||
| <HydrationBoundary state={dehydrate(queryClient)}> | ||
| <ClientPage /> | ||
| </HydrationBoundary> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Select.Trigger에
border-none을 적용하여 기본 테두리를 제거하고 있습니다. 하지만 SelectTrigger 컴포넌트 내부에서 이미 border 스타일이 정의되어 있으므로(SelectTrigger.tsx 164번 라인),border-none을 사용하면 Tailwind의 우선순위에 따라 의도대로 작동하지 않을 수 있습니다. 대신!border-0또는border-transparent를 사용하거나, SelectTrigger 컴포넌트에noBorderprop을 추가하는 것을 고려하세요.