From ea344dca19a212322e9dceca80cfa14fede77d62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=ED=98=84=EC=A1=B0?= Date: Fri, 20 Sep 2024 07:12:37 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20=EB=A6=AC=EB=B7=B0=20=EB=94=94=ED=85=8C?= =?UTF-8?q?=EC=9D=BC=20=EA=B5=AC=ED=98=84,=20test=20=EB=AA=BB=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/ReviewDetail/index.tsx | 176 ++++++++++++------ 1 file changed, 121 insertions(+), 55 deletions(-) diff --git a/frontend/src/components/ReviewDetail/index.tsx b/frontend/src/components/ReviewDetail/index.tsx index c9dc42d..c0d3690 100644 --- a/frontend/src/components/ReviewDetail/index.tsx +++ b/frontend/src/components/ReviewDetail/index.tsx @@ -1,86 +1,152 @@ -import useReviewDetailQuery from '@/queries/reviews/useReviewDetailQuery'; -import useUpdateReviewQuery from '@/queries/reviews/useUpdateReviewQuery'; -import useDeleteReviewQuery from '@/queries/reviews/useDeleteReviewQuery'; +import { useState } from 'react'; import { useParams } from 'react-router-dom'; +import Slider from 'react-slick'; +import useReviewDetailQuery from '@/queries/reviews/useReviewDetailQuery'; +import useUpdateReviewStatusQuery from '@/queries/reviews/useUpdateReviewStatusQuery'; +import useProjectMembersQuery from '@/queries/projects/useProjectMembersQuery'; +import useAuthStore from '@/stores/useAuthStore'; +import { Button } from '@/components/ui/button'; +import 'slick-carousel/slick/slick.css'; +import 'slick-carousel/slick/slick-theme.css'; -export default function ReviewDetail() { +export default function ReviewDetail(): JSX.Element { const { projectId, reviewId } = useParams<{ projectId: string; reviewId: string }>(); - const memberId = 1; + const profile = useAuthStore((state) => state.profile); + const memberId = profile?.id || 0; const { data: reviewDetail } = useReviewDetailQuery(Number(projectId), Number(reviewId), memberId); - const updateReview = useUpdateReviewQuery(); - const deleteReview = useDeleteReviewQuery(); + const { data: projectMembers } = useProjectMembersQuery(Number(projectId), memberId); - const handleUpdate = () => { - updateReview.mutate({ + const updateReviewStatus = useUpdateReviewStatusQuery(); + const [activeTab, setActiveTab] = useState<'content' | 'images'>('content'); + + const handleApprove = () => { + updateReviewStatus.mutate({ projectId: Number(projectId), reviewId: Number(reviewId), memberId, - reviewData: { - title: reviewDetail.title, - content: reviewDetail.content, - imageIds: reviewDetail.images.map((image) => image.id), - }, + reviewStatus: 'APPROVED', }); }; - const handleDelete = () => { - deleteReview.mutate({ + const handleReject = () => { + updateReviewStatus.mutate({ projectId: Number(projectId), reviewId: Number(reviewId), memberId, + reviewStatus: 'REJECTED', }); }; - if (!reviewDetail) return

Loading...

; - - const { title, content, reviewStatus, images } = reviewDetail; + const settings = { + dots: true, + infinite: true, + speed: 500, + slidesToShow: 1, + slidesToScroll: 1, + }; return ( -
-
-

{title}

-
{reviewStatus}
-
- -
-

by 김용수

-

|

-

8 hours ago

+
+
+

{reviewDetail.title}

+

+ 작성자: {reviewDetail.nickname} ({reviewDetail.email}) +

+

작성일: {new Date(reviewDetail.createAt).toLocaleDateString()}

+

수정일: {new Date(reviewDetail.updateAt).toLocaleDateString()}

-
-

내용

-

{content}

-
- -
-

이미지 목록

-
    - {images.map((image) => ( -
  • +
    + {['content', 'images'].map((tab) => ( + + ))} +
    +
+ +
+ {activeTab === 'content' ? ( +

{reviewDetail.content}

+ ) : ( +
+ {reviewDetail.images.length > 0 ? ( + + {reviewDetail.images.map((image) => ( +
+ 리뷰 이미지 +
+ ))} +
+ ) : ( +

이미지가 없습니다.

+ )} +
+ )} +
+ + {reviewDetail.reviewStatus === 'APPROVED' && ( +
+

리뷰어

+
+ 리뷰어 프로필 +
+

{reviewDetail.reviewerNickname}

+

{reviewDetail.reviewerEmail}

+
+
+
+ )} + +
+

프로젝트 멤버

+
    + {projectMembers.map((member) => ( +
  • + {member.nickname} - {member.privilegeType}
  • ))}
-
- - +
+ {reviewDetail.reviewStatus !== 'APPROVED' && ( + + )} + {reviewDetail.reviewStatus !== 'REJECTED' && ( + + )}
);