Refactor: 변경된 리뷰에 따른 리팩토링

This commit is contained in:
정현조 2024-09-27 12:26:42 +09:00
parent be182edd3a
commit ba639d0c75
3 changed files with 36 additions and 23 deletions

View File

@ -0,0 +1,18 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { approveReview } from '@/api/reviewApi';
interface ReviewStatusChangeProps {
projectId: number;
reviewId: number;
}
export default function useApproveReviewQuery({ projectId, reviewId }: ReviewStatusChangeProps) {
const queryClient = useQueryClient();
return useMutation({
mutationFn: () => approveReview(projectId, reviewId),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['reviewDetail', reviewId] });
},
});
}

View File

@ -0,0 +1,18 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { rejectReview } from '@/api/reviewApi';
interface ReviewStatusChangeProps {
projectId: number;
reviewId: number;
}
export default function useRejectReviewQuery({ projectId, reviewId }: ReviewStatusChangeProps) {
const queryClient = useQueryClient();
return useMutation({
mutationFn: () => rejectReview(projectId, reviewId),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['reviewDetail', reviewId] });
},
});
}

View File

@ -1,23 +0,0 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { updateReviewStatus } from '@/api/reviewApi';
export default function useUpdateReviewStatusQuery() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: ({
projectId,
reviewId,
memberId,
reviewStatus,
}: {
projectId: number;
reviewId: number;
memberId: number;
reviewStatus: string;
}) => updateReviewStatus(projectId, reviewId, memberId, reviewStatus),
onSuccess: (_, variables) => {
queryClient.invalidateQueries({ queryKey: ['reviewDetail', variables.projectId, variables.reviewId] });
},
});
}