Skip to content

Commit

Permalink
Merge pull request #310 from oduck-team/feature/308
Browse files Browse the repository at this point in the history
feat: 리뷰 수정 구현
  • Loading branch information
imdaxsz authored Nov 21, 2023
2 parents 5a1e721 + fafb1f6 commit 1fa7317
Show file tree
Hide file tree
Showing 28 changed files with 401 additions and 108 deletions.
2 changes: 1 addition & 1 deletion src/features/animes/routes/Detail/Ratings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
export default function Ratings({ starScoreAvg }: { starScoreAvg: number }) {
return (
<Section>
<h1>평점</h1>
<h1>별점</h1>
<AverageRatings>
<AverageRatingsOverview>
<Star size={36} weight="fill" />
Expand Down
5 changes: 5 additions & 0 deletions src/features/animes/routes/Detail/Reviews/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ export default function Reviews({
isLike={review.isLike}
likeCount={review.likeCount}
createdAt={review.createdAt}
reviewId={review.reviewId}
animeId={review.animeId}
isSpoiler={review.isSpoiler}
content={review.content}
score={review.score}
/>
</ReviewCard>
</li>
Expand Down
2 changes: 1 addition & 1 deletion src/features/animes/routes/List/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const TabItems: TabItem[] = [
},
{
id: "SCORE",
title: "평점순",
title: "별점순",
},
];

Expand Down
6 changes: 6 additions & 0 deletions src/features/bookmarks/hooks/useToggleBookmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ export default function useToggleBookmark(animeId: number) {
onSuccess: () => {
queryClient.invalidateQueries(["profile", user?.name]);
queryClient.invalidateQueries(["profile", user?.memberId, "bookmark"]);
queryClient.invalidateQueries([
"profile",
user?.memberId,
"count",
"bookmark",
]);
queryClient.invalidateQueries(["bookmark", user?.memberId, animeId]);
queryClient.invalidateQueries(["anime", animeId, user?.memberId]);
},
Expand Down
5 changes: 5 additions & 0 deletions src/features/common/routes/Home/RecentReview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ export default function RecentReview() {
isLike={data.pages[0].isLike}
likeCount={data.pages[0].likeCount}
isTimeAgo={true}
reviewId={data.pages[0].reviewId}
animeId={data.pages[0].anime.animeId}
isSpoiler={data.pages[0].isSpoiler}
content={data.pages[0].content}
score={data.pages[0].score}
/>
</ReviewCard>
)}
Expand Down
20 changes: 20 additions & 0 deletions src/features/reviews/api/mock/recentReview1.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"items": [
{
"reviewId": 10,
"name": "faberjoo",
"score": 7,
"content": "리뷰 입니다.",
"isSpoiler": false,
"isLike": true,
Expand All @@ -15,7 +17,9 @@
}
},
{
"reviewId": 9,
"name": "faberjoo",
"score": 7,
"content": "리뷰 입니다.",
"isSpoiler": false,
"isLike": true,
Expand All @@ -29,7 +33,9 @@
}
},
{
"reviewId": 8,
"name": "faberjoo",
"score": 7,
"content": "리뷰 입니다.",
"isSpoiler": false,
"isLike": true,
Expand All @@ -43,7 +49,9 @@
}
},
{
"reviewId": 7,
"name": "faberjoo",
"score": 7,
"content": "리뷰 입니다.",
"isSpoiler": false,
"isLike": true,
Expand All @@ -57,7 +65,9 @@
}
},
{
"reviewId": 6,
"name": "faberjoo",
"score": 7,
"content": "리뷰 입니다.",
"isSpoiler": false,
"isLike": true,
Expand All @@ -71,7 +81,9 @@
}
},
{
"reviewId": 5,
"name": "faberjoo",
"score": 7,
"content": "리뷰 입니다.",
"isSpoiler": false,
"isLike": true,
Expand All @@ -85,7 +97,9 @@
}
},
{
"reviewId": 4,
"name": "faberjoo",
"score": 7,
"content": "리뷰 입니다.",
"isSpoiler": false,
"isLike": true,
Expand All @@ -99,7 +113,9 @@
}
},
{
"reviewId": 3,
"name": "faberjoo",
"score": 7,
"content": "리뷰 입니다.",
"isSpoiler": false,
"isLike": true,
Expand All @@ -113,7 +129,9 @@
}
},
{
"reviewId": 2,
"name": "faberjoo",
"score": 7,
"content": "리뷰 입니다.",
"isSpoiler": false,
"isLike": true,
Expand All @@ -127,7 +145,9 @@
}
},
{
"reviewId": 1,
"name": "faberjoo",
"score": 7,
"content": "리뷰 입니다.",
"isSpoiler": false,
"isLike": true,
Expand Down
20 changes: 20 additions & 0 deletions src/features/reviews/api/mock/recentReview2.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"items": [
{
"reviewId": 20,
"name": "faberjoo",
"score": 7,
"content": "리뷰 입니다.",
"isSpoiler": false,
"isLike": true,
Expand All @@ -15,7 +17,9 @@
}
},
{
"reviewId": 19,
"name": "faberjoo",
"score": 7,
"content": "리뷰 입니다.",
"isSpoiler": false,
"isLike": true,
Expand All @@ -29,7 +33,9 @@
}
},
{
"reviewId": 18,
"name": "faberjoo",
"score": 7,
"content": "리뷰 입니다.",
"isSpoiler": false,
"isLike": true,
Expand All @@ -43,7 +49,9 @@
}
},
{
"reviewId": 17,
"name": "faberjoo",
"score": 7,
"content": "리뷰 입니다.",
"isSpoiler": false,
"isLike": true,
Expand All @@ -57,7 +65,9 @@
}
},
{
"reviewId": 16,
"name": "faberjoo",
"score": 7,
"content": "리뷰 입니다.",
"isSpoiler": false,
"isLike": true,
Expand All @@ -71,7 +81,9 @@
}
},
{
"reviewId": 15,
"name": "faberjoo",
"score": 7,
"content": "리뷰 입니다.",
"isSpoiler": false,
"isLike": true,
Expand All @@ -85,7 +97,9 @@
}
},
{
"reviewId": 14,
"name": "faberjoo",
"score": 7,
"content": "리뷰 입니다.",
"isSpoiler": false,
"isLike": true,
Expand All @@ -99,7 +113,9 @@
}
},
{
"reviewId": 13,
"name": "faberjoo",
"score": 7,
"content": "리뷰 입니다.",
"isSpoiler": false,
"isLike": true,
Expand All @@ -113,7 +129,9 @@
}
},
{
"reviewId": 12,
"name": "faberjoo",
"score": 7,
"content": "리뷰 입니다.",
"isSpoiler": false,
"isLike": true,
Expand All @@ -127,7 +145,9 @@
}
},
{
"reviewId": 11,
"name": "faberjoo",
"score": 7,
"content": "리뷰 입니다.",
"isSpoiler": false,
"isLike": true,
Expand Down
20 changes: 20 additions & 0 deletions src/features/reviews/api/mock/recentReview3.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"items": [
{
"reviewId": 30,
"name": "faberjoo",
"score": 7,
"content": "리뷰 입니다. 리뷰 입니다.리뷰 입니다.리뷰 입니다.리뷰 입니다.리뷰 입니다.리뷰 입니다.리뷰 입니다.리뷰 입니다.리뷰 입니다.리뷰 입니다.리뷰 입니다.리뷰 입니다.리뷰 입니다.리뷰 입니다.리뷰 입니다.리뷰 입니다.리뷰 입니다.리뷰 입니다.리뷰 입니다.리뷰 입니다. 리뷰 입니다. 리뷰 입니다. 리뷰 입니다.",
"isSpoiler": true,
"isLike": false,
Expand All @@ -15,7 +17,9 @@
}
},
{
"reviewId": 29,
"name": "faberjoo",
"score": 7,
"content": "리뷰 입니다.",
"isSpoiler": false,
"isLike": true,
Expand All @@ -29,7 +33,9 @@
}
},
{
"reviewId": 28,
"name": "faberjoo",
"score": 7,
"content": "리뷰 입니다.",
"isSpoiler": false,
"isLike": true,
Expand All @@ -43,7 +49,9 @@
}
},
{
"reviewId": 27,
"name": "faberjoo",
"score": 7,
"content": "리뷰 입니다.",
"isSpoiler": false,
"isLike": true,
Expand All @@ -57,7 +65,9 @@
}
},
{
"reviewId": 26,
"name": "faberjoo",
"score": 7,
"content": "리뷰 입니다.",
"isSpoiler": false,
"isLike": true,
Expand All @@ -71,7 +81,9 @@
}
},
{
"reviewId": 25,
"name": "faberjoo",
"score": 7,
"content": "리뷰 입니다.",
"isSpoiler": false,
"isLike": true,
Expand All @@ -85,7 +97,9 @@
}
},
{
"reviewId": 24,
"name": "faberjoo",
"score": 7,
"content": "리뷰 입니다.",
"isSpoiler": false,
"isLike": true,
Expand All @@ -99,7 +113,9 @@
}
},
{
"reviewId": 23,
"name": "faberjoo",
"score": 7,
"content": "리뷰 입니다.",
"isSpoiler": false,
"isLike": true,
Expand All @@ -113,7 +129,9 @@
}
},
{
"reviewId": 22,
"name": "faberjoo",
"score": 7,
"content": "리뷰 입니다.",
"isSpoiler": false,
"isLike": true,
Expand All @@ -127,7 +145,9 @@
}
},
{
"reviewId": 21,
"name": "faberjoo",
"score": 7,
"content": "리뷰 입니다.",
"isSpoiler": false,
"isLike": true,
Expand Down
2 changes: 2 additions & 0 deletions src/features/reviews/api/mock/recentReviewOnlyOne.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"items": [
{
"reviewId": 10,
"name": "faberjoo",
"score": 7,
"content": "리뷰 입니다.",
"isSpoiler": false,
"isLike": false,
Expand Down
7 changes: 5 additions & 2 deletions src/features/reviews/api/review.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ import recentReviewMock3 from "./mock/recentReview3.json";
import recentReviewOnlyOneMock from "./mock/recentReviewOnlyOne.json";

export type ReviewInfo = Omit<Review, "anime"> & {
reviewId: number;
animeId: number;
thumbnail: string;
score: number;
};

export type AddReviewDto = Pick<Review, "name" | "content"> & {
Expand All @@ -30,6 +28,11 @@ export default class ReviewApi {
return post("/short-reviews", review);
}

/** @description 리뷰 수정 요청 */
async updateReview(reviewId: number, review: AddReviewDto) {
return patch(`/short-reviews/${reviewId}`, review);
}

/** @description 한 애니의 리뷰 목록 요청 */
async getAnimeReviews(
animeId: number,
Expand Down
5 changes: 5 additions & 0 deletions src/features/reviews/api/reviewDev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ export default class ReviewDevApi {
return post("/short-reviews", review);
}

/** @description 리뷰 수정 요청 */
async updateReview(reviewId: number, review: AddReviewDto) {
return patch(`/short-reviews/${reviewId}`, review);
}

/** @description 한 애니의 리뷰 목록 요청*/
async getAnimeReviews(
animeId: number,
Expand Down
Loading

0 comments on commit 1fa7317

Please sign in to comment.