diff --git a/src/app/(user-menu)/mypage/reviews/page.tsx b/src/app/(user-menu)/mypage/reviews/page.tsx index 66690101..e5ac6356 100644 --- a/src/app/(user-menu)/mypage/reviews/page.tsx +++ b/src/app/(user-menu)/mypage/reviews/page.tsx @@ -1,16 +1,9 @@ "use client"; -import { useState } from "react"; -import Image from "next/image"; -import { cn } from "@/lib/utils"; -import { Tooltip } from "@radix-ui/themes"; -import { useQueryClient, useSuspenseQuery } from "@tanstack/react-query"; -import changeReviewStatus from "@/services/review/changeReviewStatus"; +import { useSuspenseQuery } from "@tanstack/react-query"; import getMyReviews from "@/services/review/getMyReviews"; -import Icon from "@/components/_common/Icon"; -import { SingleSelector } from "@/components/_common/Selector"; -import { CardTooltip } from "@/constants/cardTooltip"; -import { subBoxStyles, subMyPageTextStyles } from "@/constants/commonStyle"; +import MyCardReview from "@/components/containers/myReviews/MyCardReview"; +import MyCommentReview from "@/components/containers/myReviews/MyCommentReview"; import { MyReviewKey } from "@/constants/queryKeys"; const MyReviewsPage = () => { @@ -19,96 +12,20 @@ const MyReviewsPage = () => { queryFn: () => getMyReviews(), staleTime: 10000, }); - const [selectedId, setSelectedId] = useState(null); - const queryClient = useQueryClient(); - - const selectedReviews = myReviewData.reviews.find( - (review) => review.steadyId === Number(selectedId), - ); - - const handlePublicReview = async (reviewId: number) => { - await changeReviewStatus(reviewId.toString()); - queryClient.invalidateQueries({ queryKey: MyReviewKey }); - }; return (
내가 받은 리뷰
-
-
받은 카드
-
- {myReviewData.userCards.map((card, index) => ( -
- - 카드 이미지 - - -
- {`( ${card.count} )`} -
-
- ))} -
-
-
-
한 줄 평
- ({ - value: review.steadyId.toString(), - label: review.steadyName, - }))} - initialLabel="전체" - onSelectedChange={(value) => setSelectedId(value)} - className="h-60" - /> -
- {selectedReviews && - selectedReviews.reviews.map((review) => ( -
-
- {review.comment} -
- -
- ))} -
-
+ +
); }; diff --git a/src/components/containers/myReviews/MyCardReview.tsx b/src/components/containers/myReviews/MyCardReview.tsx new file mode 100644 index 00000000..8c3c9bbd --- /dev/null +++ b/src/components/containers/myReviews/MyCardReview.tsx @@ -0,0 +1,46 @@ +import Image from "next/image"; +import { cn } from "@/lib/utils"; +import { Tooltip } from "@radix-ui/themes"; +import type { MyReviewsType } from "@/services/types"; +import { CardTooltip } from "@/constants/cardTooltip"; +import { subBoxStyles, subMyPageTextStyles } from "@/constants/commonStyle"; + +const MyCardReview = ({ + myReviewData, + title, +}: { + myReviewData: MyReviewsType; + title: string; +}) => { + return ( +
+
{title}
+
+ {myReviewData.userCards.map((card, index) => ( +
+ + 카드 이미지 + + +
+ {`( ${card.count} )`} +
+
+ ))} +
+
+ ); +}; + +export default MyCardReview; diff --git a/src/components/containers/myReviews/MyCommentReview.tsx b/src/components/containers/myReviews/MyCommentReview.tsx new file mode 100644 index 00000000..6cfc0149 --- /dev/null +++ b/src/components/containers/myReviews/MyCommentReview.tsx @@ -0,0 +1,80 @@ +import { useState } from "react"; +import { cn } from "@/lib/utils"; +import { useQueryClient } from "@tanstack/react-query"; +import changeReviewStatus from "@/services/review/changeReviewStatus"; +import type { MyReviewsType } from "@/services/types"; +import Icon from "@/components/_common/Icon"; +import { SingleSelector } from "@/components/_common/Selector"; +import { subMyPageTextStyles } from "@/constants/commonStyle"; +import { MyReviewKey } from "@/constants/queryKeys"; + +const MyCommentReview = ({ + myReviewData, + title, +}: { + myReviewData: MyReviewsType; + title: string; +}) => { + const [selectedId, setSelectedId] = useState(null); + const queryClient = useQueryClient(); + + const selectedReviews = myReviewData.reviews.find( + (review) => review.steadyId === Number(selectedId), + ); + + const handlePublicReview = async (reviewId: number) => { + await changeReviewStatus(reviewId.toString()); + queryClient.invalidateQueries({ queryKey: MyReviewKey }); + }; + + return ( +
+
{title}
+ ({ + value: review.steadyId.toString(), + label: review.steadyName, + }))} + initialLabel="전체" + onSelectedChange={(value) => setSelectedId(value)} + className="h-60" + /> +
+ {selectedReviews && + selectedReviews.reviews.map((review) => ( +
+
+ {review.comment} +
+ +
+ ))} +
+
+ ); +}; + +export default MyCommentReview;