-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* style: TopNavigation 스타일 수정 * feat: BookGroupInfo api 연결 * style(TopNaviation): CenterItem px 수정 * fix: BookGroupInfo 스토리 제거 * style(BookInfoCard): 제목 text-overflow 설정 * feat: CommentList api 연결 * fix: build 오류 수정 * refactor: group, user type 정리 * refactor: useBookGroupQuery default export * refactor: MemeberCapacity 시맨틱한 태그로 수정 - span -> p
- Loading branch information
Showing
23 changed files
with
318 additions
and
268 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,52 @@ | ||
'use client'; | ||
|
||
import { Flex } from '@chakra-ui/react'; | ||
import TopNavigation from '@/ui/Base/TopNavigation'; | ||
import BookGroupInfo from '@/v1/bookGroup/detail/BookGroupInfo'; | ||
import { IconArrowLeft, IconHamburger, IconPost } from '@public/icons'; | ||
|
||
import GroupDetail from '@/ui/Group/GroupDetail'; | ||
import { useBookGroupTitle } from '@/queries/group/useBookGroupQuery'; | ||
import CommentList from '@/v1/bookGroup/detail/CommentList'; | ||
|
||
const GroupDetailPage = ({ | ||
const DetailBookGroupPage = ({ | ||
params: { groupId }, | ||
}: { | ||
params: { groupId: number }; | ||
}) => { | ||
return ( | ||
<Flex direction="column" justify="center"> | ||
<GroupDetail bookGroupId={Number(groupId)} /> | ||
</Flex> | ||
<> | ||
<BookGroupNavigation groupId={groupId} /> | ||
<div className="flex flex-col gap-[2rem]"> | ||
<BookGroupInfo groupId={groupId} /> | ||
<div className="flex flex-col gap-[1rem]"> | ||
<Heading text="게시글" /> | ||
<CommentList groupId={groupId} /> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default GroupDetailPage; | ||
export default DetailBookGroupPage; | ||
|
||
const BookGroupNavigation = ({ groupId }: { groupId: number }) => { | ||
const { data: title } = useBookGroupTitle(groupId); | ||
|
||
return ( | ||
<TopNavigation> | ||
<TopNavigation.LeftItem> | ||
<IconArrowLeft /> | ||
</TopNavigation.LeftItem> | ||
<TopNavigation.CenterItem textAlign="left"> | ||
{title} | ||
</TopNavigation.CenterItem> | ||
<TopNavigation.RightItem> | ||
<IconPost /> | ||
<IconHamburger /> | ||
</TopNavigation.RightItem> | ||
</TopNavigation> | ||
); | ||
}; | ||
|
||
const Heading = ({ text }: { text: string }) => ( | ||
<p className=" text-xl font-bold">{text}</p> | ||
); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { APIGroupDetail } from '@/types/group'; | ||
|
||
const bookGroupKeys = { | ||
all: ['bookGroup'] as const, | ||
details: () => [...bookGroupKeys.all, 'detail'] as const, | ||
detail: (id: APIGroupDetail['bookGroupId']) => | ||
[...bookGroupKeys.details(), id] as const, | ||
comments: (id: APIGroupDetail['bookGroupId']) => | ||
[...bookGroupKeys.details(), id, 'comments'] as const, | ||
}; | ||
|
||
export default bookGroupKeys; |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { QueryOptions } from '@/types/query'; | ||
import { | ||
APIGroupCommentPagination, | ||
APIGroupDetail, | ||
BookGroupComment, | ||
} from '@/types/group'; | ||
|
||
import GroupAPI from '@/apis/group'; | ||
import bookGroupKeys from './key'; | ||
|
||
const transformComments = ({ bookGroupComments }: APIGroupCommentPagination) => | ||
bookGroupComments.map<BookGroupComment>(comment => ({ | ||
id: comment.commentId, | ||
writer: { | ||
id: comment.userId, | ||
profileImageSrc: comment.userProfileImage, | ||
name: comment.nickname, | ||
}, | ||
createdAt: comment.createdAt, | ||
content: comment.contents, | ||
})); | ||
|
||
const useBookGroupCommentsQuery = <TData = APIGroupCommentPagination>( | ||
groupId: APIGroupDetail['bookGroupId'], | ||
select?: QueryOptions<APIGroupCommentPagination, TData>['select'] | ||
) => | ||
useQuery({ | ||
queryKey: bookGroupKeys.comments(groupId), | ||
queryFn: () => | ||
GroupAPI.getGroupComments({ bookGroupId: groupId }).then( | ||
({ data }) => data | ||
), | ||
select, | ||
}); | ||
|
||
export default useBookGroupCommentsQuery; | ||
|
||
export const useBookGroupComments = (groupId: APIGroupDetail['bookGroupId']) => | ||
useBookGroupCommentsQuery(groupId, transformComments); |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import { APIGroupDetail, BookGroupDetail } from '@/types/group'; | ||
import { QueryOptions } from '@/types/query'; | ||
|
||
import GroupAPI from '@/apis/group'; | ||
import bookGroupKeys from './key'; | ||
|
||
const transformBookGroupDetail = (data: APIGroupDetail) => | ||
({ | ||
title: data.title, | ||
description: data.introduce, | ||
bookId: data.book.id, | ||
owner: { isMe: data.isOwner, id: data.owner.id }, | ||
date: { start: data.startDate, end: data.endDate }, | ||
memberCount: { current: data.currentMemberCount, max: data.maxMemberCount }, | ||
isPublic: data.isPublic, | ||
isMember: data.isGroupMember, | ||
} as BookGroupDetail); | ||
|
||
export const useBookGroupQuery = <TData = APIGroupDetail>( | ||
groupId: APIGroupDetail['bookGroupId'], | ||
select: QueryOptions<APIGroupDetail, TData>['select'] | ||
) => | ||
useQuery({ | ||
queryKey: bookGroupKeys.detail(groupId), | ||
queryFn: () => | ||
GroupAPI.getGroupDetailInfo({ bookGroupId: groupId }).then( | ||
({ data }) => data | ||
), | ||
select, | ||
}); | ||
|
||
export default useBookGroupQuery; | ||
|
||
export const useBookGroup = (groupId: APIGroupDetail['bookGroupId']) => | ||
useBookGroupQuery(groupId, transformBookGroupDetail); | ||
|
||
export const useBookGroupTitle = (groupId: APIGroupDetail['bookGroupId']) => | ||
useBookGroupQuery(groupId, data => data.title); |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { APIUser } from '@/types/user'; | ||
|
||
const userKeys = { | ||
all: ['user'] as const, | ||
details: () => [...userKeys.all, 'detail'] as const, | ||
detail: (id: APIUser['userId']) => [...userKeys.details(), id] as const, | ||
me: () => [...userKeys.details(), 'me'] as const, | ||
}; | ||
|
||
export default userKeys; |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
import { UseQueryOptions } from '@tanstack/react-query'; | ||
|
||
export type QueryOptions<T> = UseQueryOptions<Awaited<T>, unknown, T, string[]>; | ||
export type QueryOptions< | ||
TQueryFnData, | ||
TQueryData = TQueryFnData | ||
> = UseQueryOptions<Awaited<TQueryFnData>, unknown, TQueryData, string[]>; |
Oops, something went wrong.