-
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
[#453] [모임] 모임 목록 페이지 개선 #475
Merged
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
75a4b8f
fix: api 응답과 타입 동기화
gxxrxn a8210de
refactor: SimpleBookGroupCard 리팩터링
gxxrxn e101c65
feat: DetailBookGroupCard 스켈레톤 컴포넌트 작성
gxxrxn dc592e9
feat: 내가 참여한 모임 suspense 적용, GroupPage 리팩토링
gxxrxn a6f9d1d
fix: group api 타입 수정, query로 인한 빌드 오류 해결
gxxrxn 3f92116
refactor: bookgroup 파스칼 케이스로 변경
gxxrxn 394f50b
fix: 비로그인 시 query 런타임 오류 해결
gxxrxn c0e5ae7
fix: 로그인되어있을 때만 내가 참여한 모임 스켈레톤 렌더링되도록 수정
gxxrxn f5e15be
fix: 내가 참여한 모임 리스트 하이드레이션 오류 해결
gxxrxn 2cd1e16
fix: 독서모임 페이지 무한스크롤 ref 최하단으로 이동
gxxrxn 4480340
fix: page skeleton 적용
gxxrxn 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
There are no files selected for viewing
This file contains 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,31 +1,89 @@ | ||
'use client'; | ||
|
||
import { useEffect } from 'react'; | ||
import { useInView } from 'react-intersection-observer'; | ||
|
||
import SSRSafeSuspense from '@/components/SSRSafeSuspense'; | ||
import TopHeader from '@/v1/base/TopHeader'; | ||
import SearchGroup from '@/v1/bookGroup/SearchGroup'; | ||
import SimpleBookGroupCard from '@/v1/bookGroup/SimpleBookGroupCard'; | ||
import DetailBookGroupCard from '@/v1/bookGroup/DetailBookGroupCard'; | ||
import SearchGroupInput from '@/v1/bookGroup/SearchGroup'; | ||
import SimpleBookGroupCard, { | ||
SimpleBookGroupCardSkeleton, | ||
} from '@/v1/bookGroup/SimpleBookGroupCard'; | ||
import DetailBookGroupCard, { | ||
DetailBookGroupCardSkeleton, | ||
} from '@/v1/bookGroup/DetailBookGroupCard'; | ||
|
||
import useEntireGroupsQuery from '@/queries/group/useEntireGroupsQuery'; | ||
import useMyGroupsQuery from '@/queries/group/useMyGroupQuery'; | ||
import { Skeleton, VStack } from '@chakra-ui/react'; | ||
import { useEffect } from 'react'; | ||
import { useInView } from 'react-intersection-observer'; | ||
import { useMyProfileId } from '@/queries/user/useMyProfileQuery'; | ||
import { isAuthed } from '@/utils/helpers'; | ||
|
||
const GroupPage = () => { | ||
const handleSearchInputClick = () => { | ||
alert('아직 준비 중인 기능이에요.'); | ||
}; | ||
|
||
return ( | ||
<> | ||
<TopHeader text="Group" /> | ||
<div className="flex w-full flex-col gap-[2rem]"> | ||
<SearchGroupInput onClick={handleSearchInputClick} /> | ||
<SSRSafeSuspense fallback={<MyBookGroupListSkeleton />}> | ||
{isAuthed() && <MyBookGroupList />} | ||
</SSRSafeSuspense> | ||
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. 👍 |
||
<EntireBookGroupList /> | ||
</div> | ||
{/* <Link href={'/group/create'}> | ||
<FloatingButton position="bottom-right" /> | ||
</Link> */} | ||
</> | ||
); | ||
}; | ||
|
||
export default GroupPage; | ||
|
||
const MyBookGroupList = () => { | ||
const { | ||
data: { bookGroups }, | ||
} = useMyGroupsQuery({ enabled: isAuthed() }); | ||
const { data: myId } = useMyProfileId({ enabled: isAuthed() }); | ||
|
||
return ( | ||
<div className="flex gap-[1rem] overflow-scroll"> | ||
{bookGroups.map(({ title, book, bookGroupId, owner }) => ( | ||
<SimpleBookGroupCard | ||
key={bookGroupId} | ||
title={title} | ||
imageSource={book.imageUrl} | ||
isOwner={owner.id === myId} | ||
bookGroupId={bookGroupId} | ||
/> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
const MyBookGroupListSkeleton = () => ( | ||
<div className="flex min-h-[16.3rem] animate-pulse gap-[1rem] overflow-hidden"> | ||
<SimpleBookGroupCardSkeleton /> | ||
<SimpleBookGroupCardSkeleton /> | ||
<SimpleBookGroupCardSkeleton /> | ||
<SimpleBookGroupCardSkeleton /> | ||
</div> | ||
); | ||
|
||
const EntireBookGroupList = () => { | ||
const { ref, inView } = useInView(); | ||
|
||
const { | ||
isSuccess: entireGroupsIsSuccess, | ||
data: entireGroupsData, | ||
isSuccess, | ||
data, | ||
isLoading, | ||
fetchNextPage, | ||
hasNextPage, | ||
isFetchingNextPage, | ||
} = useEntireGroupsQuery(); | ||
|
||
const { isSuccess: myGroupsIsSuccess, data: myGroupsData } = | ||
useMyGroupsQuery(); | ||
|
||
useEffect(() => { | ||
if (inView && hasNextPage) { | ||
fetchNextPage(); | ||
|
@@ -34,83 +92,53 @@ const GroupPage = () => { | |
|
||
if (isLoading) | ||
return ( | ||
<VStack gap="0.5rem" align="stretch" w="100%"> | ||
<Skeleton height="9rem" /> | ||
<Skeleton height="28rem" /> | ||
<Skeleton height="28rem" /> | ||
<Skeleton height="28rem" /> | ||
</VStack> | ||
<div className="flex flex-col gap-[1rem]"> | ||
<DetailBookGroupCardSkeleton /> | ||
<DetailBookGroupCardSkeleton /> | ||
<DetailBookGroupCardSkeleton /> | ||
<DetailBookGroupCardSkeleton /> | ||
</div> | ||
); | ||
|
||
return ( | ||
<> | ||
<TopHeader text="Group" /> | ||
<div className="mt-[2rem] flex w-full flex-col gap-[1.5rem]"> | ||
<SearchGroup | ||
onClick={() => { | ||
alert('추후 업데이트 될 예정입니다.'); | ||
}} | ||
/> | ||
<div className="mt-[0.7rem] flex gap-[1rem] overflow-scroll"> | ||
{myGroupsIsSuccess && | ||
myGroupsData.bookGroups.map(group => { | ||
const { title, book, bookGroupId } = group; | ||
return ( | ||
//API isOwner 값이 존재하지 않아 비교하는 로직 추가 필요 | ||
<SimpleBookGroupCard | ||
<div className="flex flex-col gap-[1rem]"> | ||
{isSuccess && | ||
data.pages.map(({ bookGroups }) => | ||
bookGroups.map( | ||
({ | ||
bookGroupId, | ||
title, | ||
introduce, | ||
book, | ||
startDate, | ||
endDate, | ||
owner, | ||
memberCount, | ||
commentCount, | ||
isPublic, | ||
}) => ( | ||
<DetailBookGroupCard | ||
key={bookGroupId} | ||
title={title} | ||
imageSource={book.imageUrl} | ||
isOwner={false} | ||
description={introduce} | ||
bookImageSrc={book.imageUrl} | ||
date={{ start: startDate, end: endDate }} | ||
owner={{ | ||
name: owner.nickname, | ||
profileImageSrc: owner.profileUrl, | ||
}} | ||
memberCount={memberCount} | ||
commentCount={commentCount} | ||
isPublic={isPublic} | ||
bookGroupId={bookGroupId} | ||
/> | ||
); | ||
})} | ||
</div> | ||
<div className="flex flex-col gap-[1rem]"> | ||
{entireGroupsIsSuccess && | ||
entireGroupsData.pages.map(groups => { | ||
return groups.bookGroups.map(group => { | ||
const { | ||
title, | ||
introduce, | ||
book, | ||
startDate, | ||
endDate, | ||
owner, | ||
currentMemberCount, | ||
commentCount, | ||
isPublic, | ||
bookGroupId, | ||
} = group; | ||
return ( | ||
<DetailBookGroupCard | ||
key={bookGroupId} | ||
title={title} | ||
description={introduce} | ||
bookImageSrc={book.imageUrl} | ||
date={{ start: startDate, end: endDate }} | ||
owner={{ | ||
name: owner.nickname, | ||
profileImageSrc: owner.profileUrl, | ||
}} | ||
memberCount={currentMemberCount} | ||
commentCount={commentCount} | ||
isPublic={isPublic} | ||
bookGroupId={bookGroupId} | ||
/> | ||
); | ||
}); | ||
})} | ||
</div> | ||
) | ||
) | ||
)} | ||
</div> | ||
{isFetchingNextPage && <DetailBookGroupCardSkeleton />} | ||
<div ref={ref} /> | ||
{isFetchingNextPage && <Skeleton w="100%" height="28rem" />} | ||
{/* <Link href={'/group/create'}> | ||
<FloatingButton position="bottom-right" /> | ||
</Link> */} | ||
</> | ||
); | ||
}; | ||
|
||
export default GroupPage; |
This file contains 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 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 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 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 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.
just comment;
다양한 클라이언트에서 일관된 경험을 제공하기 위해서 alert 을 대체할 컴포넌트가 있으면 좋긴 하겠네요.
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.
@minjongbaek 흠.. 구현되어 있는 Toast나 Modal을 사용하면 어떨까요?
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.
@gxxrxn 그것도 좋은 방법이네요! 그런데 다시 보니까 어차피 곧 지워질 코드로 보이네요 😅