-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from dnd-side-project/feature/76-review-like
리뷰 좋아요 기능 추가
- Loading branch information
Showing
18 changed files
with
212 additions
and
73 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import FiestaInstance from "@/apis/FiestaInstance"; | ||
import { FIESTA_ENDPOINTS } from "@/config"; | ||
|
||
import { ReviewLikeResponse } from "./reviewLikeType"; | ||
|
||
const ENDPOINT = FIESTA_ENDPOINTS.reviews; | ||
|
||
export async function patchReviewLike({ | ||
reviewId, | ||
}: { | ||
reviewId: string | number; | ||
}) { | ||
const endpoint = ENDPOINT.like(reviewId); | ||
const data = await FiestaInstance.patch<ReviewLikeResponse>(endpoint); | ||
|
||
return data; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export type ReviewLikeResponse = { | ||
reviewId: number; | ||
likeCount: number; | ||
isLiked: boolean; | ||
}; |
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
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
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useMutation, useQueryClient } from "@tanstack/react-query"; | ||
|
||
import { topKeywordFestivalKeys } from "@/apis/festivals/topKeywordFestival/topKeywordFestivalKeys"; | ||
import { deleteReview } from "@/apis/review/reviewDelete/reviewDelete"; | ||
import { reviewsKeys } from "@/apis/review/reviews/reviewKeys"; | ||
import type { Review } from "@/apis/review/reviews/reviewsType"; | ||
|
||
const useDeleteReview = (review: Review) => { | ||
const queryClient = useQueryClient(); | ||
|
||
const { mutate: deleteReviewMutate, isPending: isDeleting } = useMutation({ | ||
mutationFn: async (reviewId: number) => await deleteReview(reviewId), | ||
onSuccess: () => { | ||
queryClient.invalidateQueries({ queryKey: reviewsKeys.all }); | ||
queryClient.invalidateQueries({ | ||
queryKey: topKeywordFestivalKeys.list({ | ||
festivalId: review.festivalId, | ||
}), | ||
}); | ||
}, | ||
}); | ||
|
||
return { deleteReviewMutate, isDeleting }; | ||
}; | ||
|
||
export default useDeleteReview; |
Oops, something went wrong.