-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FE] Feat #133: 리뷰 디테일 페이지 버킷 디테일 컴포넌트 이용하여 UI 및 기능 구현
Change-Id: Ica5b8fdb1474b33a0e800c561567cc32126241fd
- Loading branch information
1 parent
c4ed507
commit 66fde03
Showing
26 changed files
with
993 additions
and
80 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,114 @@ | ||
import { useEffect, useState } from 'react' | ||
import { useParams } from 'react-router' | ||
import { useQuery } from '@tanstack/react-query' | ||
|
||
import ReviewMoreButton from '../component/ReviewMoreButton' | ||
import WithHeaderLayout from '../../../components/layout/WithHeaderLayout' | ||
import ReviewBucket from '../component/ReviewBucket' | ||
import UserProfile from '../../../components/UserProfile/UserProfile' | ||
import ShareButton from '../component/ShareButton' | ||
import Reaction from '../component/Reaction' | ||
import CommentList from '../component/Comment/CommentList' | ||
import CommentInput from '../component/Comment/CommentInput' | ||
import InterestTag from '../component/InterestTag' | ||
|
||
import { useRouter } from '../../../hooks/useRouter' | ||
import { useDetailReviewStore } from '../../../store/detailStore' | ||
import { getReviewDetailQuery } from '../api' | ||
import { isMyUserType } from '../../../utils/typeFilter' | ||
|
||
import { IReviewDetail } from '../../../types/bucket' | ||
import { IMenu, IMenuFunc } from '../../../interfaces' | ||
import { icons } from '../../../constants/header-icons' | ||
|
||
const ReviewDetail = () => { | ||
return <div>리뷰상세 페이지</div> | ||
const { setDetailReview, resetDetailReview } = useDetailReviewStore() | ||
const [isInputShown, setIsInputShown] = useState(false) | ||
const [isInputFocused, setIsInputFocused] = useState(false) | ||
|
||
const { goBack } = useRouter() | ||
const { reviewId } = useParams() | ||
|
||
// :: Validate reviewId | ||
// reviewId Path variable로 Number 값이 아닌 값이 들어오면 이전 페이지로 이동 | ||
useEffect(() => { | ||
if (isNaN(Number(reviewId))) { | ||
goBack() | ||
return | ||
} | ||
}, []) | ||
|
||
// :: Get Review data | ||
const { isLoading, data: reviewDetailInfo } = useQuery<IReviewDetail>({ | ||
queryKey: ['reviewDetailInfo', reviewId], | ||
queryFn: getReviewDetailQuery, | ||
}) | ||
useEffect(() => { | ||
resetDetailReview() | ||
reviewDetailInfo && setDetailReview(reviewDetailInfo) | ||
}, [reviewDetailInfo]) | ||
|
||
// :: Header | ||
const bucketRightMenu = | ||
reviewDetailInfo && isMyUserType(reviewDetailInfo.writer) ? <ReviewMoreButton /> : undefined | ||
const handleLeftFunc = () => { | ||
goBack() | ||
} | ||
const headerMenu: IMenu = { | ||
left: icons.BACK, | ||
center: `${reviewDetailInfo ? reviewDetailInfo.writer.userNickname + '의 꿈:틀' : '꿈:틀'}`, | ||
right: bucketRightMenu, | ||
} | ||
const headerFunc: IMenuFunc = { left_func: handleLeftFunc, right_func: undefined } | ||
|
||
// :: Rendering | ||
if (reviewId === undefined) { | ||
goBack() | ||
return | ||
} | ||
return ( | ||
<> | ||
<WithHeaderLayout headerMenu={headerMenu} headerFunc={headerFunc}> | ||
<p className="text-[28px] font-bold mt-6 leading-none">{reviewDetailInfo?.reviewTitle}</p> | ||
<div className="mt-3 mb-6"> | ||
<UserProfile type="detail" isLoading={isLoading} userInfo={reviewDetailInfo?.writer} /> | ||
</div> | ||
<section className="px-3"> | ||
<ReviewBucket | ||
isLoading={isLoading} | ||
title={reviewDetailInfo?.bucketTitle} | ||
color={reviewDetailInfo?.bucketColor} | ||
dayCount={reviewDetailInfo?.daysSinceDream} | ||
/> | ||
</section> | ||
|
||
{isLoading || reviewDetailInfo === undefined ? ( | ||
<>{/* Todo: skeleton 추가 */}</> | ||
) : ( | ||
<> | ||
{/* 날짜 */} | ||
<p className="mt-6 text-base text-disabled">{reviewDetailInfo.reviewCreatedDate}</p> | ||
{/* 태그 */} | ||
<ul className="mt-3 bg-white"> | ||
{reviewDetailInfo.categories.map((category, index) => ( | ||
<InterestTag tag={category} key={`category-${index}`} /> | ||
))} | ||
</ul> | ||
<div className="flex gap-3 my-8"> | ||
<ShareButton /> | ||
</div> | ||
<Reaction id={reviewId} /> | ||
<CommentList | ||
isInputFocused={isInputFocused} | ||
setIsInputShown={setIsInputShown} | ||
id={reviewId} | ||
/> | ||
</> | ||
)} | ||
</WithHeaderLayout> | ||
{isInputShown && <CommentInput reviewId={reviewId} setIsInputFocused={setIsInputFocused} />} | ||
</> | ||
) | ||
} | ||
|
||
export default ReviewDetail |
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
Oops, something went wrong.