diff --git a/src/components/Layout/Sidebar.tsx b/src/components/Layout/Sidebar.tsx
index a762ab34..64d7c5db 100644
--- a/src/components/Layout/Sidebar.tsx
+++ b/src/components/Layout/Sidebar.tsx
@@ -112,7 +112,7 @@ export default function Sidebar({
{user && (
<>
-
+
{title}
- {starScoreAvg === 0 ? "평가 전" : starScoreAvg / 2}
+
+ {starScoreAvg === 0 ? "평가 전" : calcStarRatingAvg(starScoreAvg)}
+
diff --git a/src/features/animes/hooks/useAnime.ts b/src/features/animes/hooks/useAnime.ts
index ff0cd32a..3bb15773 100644
--- a/src/features/animes/hooks/useAnime.ts
+++ b/src/features/animes/hooks/useAnime.ts
@@ -2,6 +2,7 @@ import { useQuery } from "@tanstack/react-query";
import useAuth from "@/features/auth/hooks/useAuth";
import { useApi } from "@/hooks/useApi";
+import { calcStarRatingAvg } from "@/utils/common";
export default function useAnime(animeId: number) {
const { animeApi } = useApi();
@@ -17,9 +18,7 @@ export default function useAnime(animeId: number) {
queryFn: () => animeApi.getById(animeId),
});
- const starRatingAvg = data
- ? Math.floor((data.starRatingAvg / 2) * 10) / 10
- : 0;
+ const starRatingAvg = calcStarRatingAvg(data?.starRatingAvg);
return { starRatingAvg, anime, isLoading };
}
diff --git a/src/features/reviews/hook/useEvaluation.ts b/src/features/reviews/hook/useEvaluation.ts
index 82cdc993..492e917c 100644
--- a/src/features/reviews/hook/useEvaluation.ts
+++ b/src/features/reviews/hook/useEvaluation.ts
@@ -33,6 +33,8 @@ export default function useEvaluation(animeId: number) {
queryClient.invalidateQueries(["evaluation", animeId, user?.memberId]);
// 애니 평균 평점 조회 query 무효화
queryClient.invalidateQueries(["averageRating", animeId, user?.memberId]);
+ // 프로필 북마크 query 무효화
+ queryClient.invalidateQueries(["profile", user?.memberId, "bookmark"]);
},
onError: (error) => {
if (error instanceof AxiosError && error.response?.status) {
diff --git a/src/features/users/routes/Profile/TabMenu/BookmarkCard.style.ts b/src/features/users/routes/Profile/TabMenu/BookmarkCard.style.ts
index cd1bf4e7..f5b248e1 100644
--- a/src/features/users/routes/Profile/TabMenu/BookmarkCard.style.ts
+++ b/src/features/users/routes/Profile/TabMenu/BookmarkCard.style.ts
@@ -8,23 +8,30 @@ export const BookmarkCardContainer = styled.div`
padding: 16px;
margin: 0 -16px;
cursor: pointer;
- transition: background-color ease 0.1s;
@media (hover: hover) and (pointer: fine) {
- &:hover {
- background-color: #fdfdfd;
+ &:hover img {
+ transform: scale(1.2);
}
}
`;
-export const Image = styled.img`
+export const ImageContainer = styled.div`
flex-shrink: 0;
width: 80px;
height: 100px;
+ overflow: hidden;
border-radius: 4px;
- background-color: #d9d9d9;
margin-right: 8px;
`;
+export const Image = styled.img`
+ width: 100%;
+ object-fit: cover;
+ background-color: #d9d9d9;
+ overflow: hidden;
+ transition: transform ease 0.2s;
+`;
+
export const InfoContainer = styled.div`
display: flex;
flex-direction: column;
diff --git a/src/features/users/routes/Profile/TabMenu/BookmarkCard.tsx b/src/features/users/routes/Profile/TabMenu/BookmarkCard.tsx
index 5663effd..152c2697 100644
--- a/src/features/users/routes/Profile/TabMenu/BookmarkCard.tsx
+++ b/src/features/users/routes/Profile/TabMenu/BookmarkCard.tsx
@@ -2,11 +2,14 @@ import { AnimatePresence } from "framer-motion";
import { useState } from "react";
import { useNavigate } from "react-router-dom";
+import { calcStarRatingAvg } from "@/utils/common";
+
import {
BookmarkCardContainer,
BottomContainer,
CreatedDate,
Image,
+ ImageContainer,
InfoContainer,
MyScore,
RatingContainer,
@@ -37,20 +40,28 @@ export default function BookmarkCard({ bookmark, isMine }: BookmarkCardProps) {
return (
<>
-
+
+
+
{bookmark.title}
- 평균 {bookmark.avgScore / 2}
+
+ {bookmark.avgScore < 0 ? (
+ 평가전
+ ) : (
+ `별점 ${calcStarRatingAvg(bookmark.avgScore)}`
+ )}
+
{bookmark.myScore >= 0 && (
<>
- 내 평점 {bookmark.myScore / 2}
+ 내 별점 {bookmark.myScore / 2}
>
)}
{bookmark.myScore < 0 && 평가전}
diff --git a/src/utils/common.ts b/src/utils/common.ts
index 8dc2382e..5ff63e1d 100644
--- a/src/utils/common.ts
+++ b/src/utils/common.ts
@@ -11,3 +11,7 @@ export function compactNumber(data: number | string, lang: Lang = "en-US") {
maximumFractionDigits: 1,
}).format(data);
}
+
+export function calcStarRatingAvg(score: number | undefined) {
+ return score ? Math.floor((score / 2) * 10) / 10 : 0;
+}