Refactor: 리뷰 api 변경에 따른 리팩토링
This commit is contained in:
parent
6af651d96d
commit
92d4366583
@ -1,13 +1,5 @@
|
||||
import api from '@/api/axiosConfig';
|
||||
import {
|
||||
ModelRequest,
|
||||
ModelResponse,
|
||||
ProjectModelsResponse,
|
||||
ModelCategoryResponse,
|
||||
ModelTrainRequest,
|
||||
ResultResponse,
|
||||
ReportResponse,
|
||||
} from '@/types';
|
||||
import { ModelRequest, ModelResponse, ProjectModelsResponse, ModelCategoryResponse, ModelTrainRequest } from '@/types';
|
||||
|
||||
export async function updateModelName(projectId: number, modelId: number, modelData: ModelRequest) {
|
||||
return api.put<ModelResponse>(`/projects/${projectId}/models/${modelId}`, modelData).then(({ data }) => data);
|
||||
@ -28,11 +20,3 @@ export async function addProjectModel(projectId: number, modelData: ModelRequest
|
||||
export async function getModelCategories(modelId: number) {
|
||||
return api.get<ModelCategoryResponse[]>(`/models/${modelId}/categories`).then(({ data }) => data);
|
||||
}
|
||||
|
||||
export async function getModelResults(modelId: number) {
|
||||
return api.get<ResultResponse[]>(`/results/model/${modelId}`).then(({ data }) => data);
|
||||
}
|
||||
|
||||
export async function getModelReports(projectId: number, modelId: number) {
|
||||
return api.get<ReportResponse[]>(`/projects/${projectId}/reports/model/${modelId}`).then(({ data }) => data);
|
||||
}
|
||||
|
12
frontend/src/api/reportApi.ts
Normal file
12
frontend/src/api/reportApi.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import api from '@/api/axiosConfig';
|
||||
import { ReportResponse } from '@/types';
|
||||
|
||||
export async function getCompletedModelReport(projectId: number, modelId: number) {
|
||||
return api.get<ReportResponse[]>(`/projects/${projectId}/reports/models/${modelId}`).then(({ data }) => data);
|
||||
}
|
||||
|
||||
export async function getTrainingModelReport(projectId: number, modelId: number) {
|
||||
return api
|
||||
.get<ReportResponse[]>(`/projects/${projectId}/reports/models/${modelId}/progress`)
|
||||
.then(({ data }) => data);
|
||||
}
|
6
frontend/src/api/resultApi.ts
Normal file
6
frontend/src/api/resultApi.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import api from '@/api/axiosConfig';
|
||||
import { ResultResponse } from '@/types';
|
||||
|
||||
export async function getModelResult(modelId: number) {
|
||||
return api.get<ResultResponse[]>(`/results/model/${modelId}`).then(({ data }) => data);
|
||||
}
|
@ -37,18 +37,14 @@ export async function deleteReview(projectId: number, reviewId: number, memberId
|
||||
.then(({ data }) => data);
|
||||
}
|
||||
|
||||
// 리뷰 상태 변경
|
||||
export async function updateReviewStatus(projectId: number, reviewId: number, memberId: number, reviewStatus: string) {
|
||||
return api
|
||||
.put<ReviewResponse>(
|
||||
`/projects/${projectId}/reviews/${reviewId}/status`,
|
||||
{ reviewStatus },
|
||||
{
|
||||
params: { memberId },
|
||||
}
|
||||
)
|
||||
.then(({ data }) => data);
|
||||
export async function approveReview(projectId: number, reviewId: number) {
|
||||
return api.put(`/projects/${projectId}/reviews/${reviewId}/approve`);
|
||||
}
|
||||
|
||||
export async function rejectReview(projectId: number, reviewId: number) {
|
||||
return api.put(`/projects/${projectId}/reviews/${reviewId}/reject`);
|
||||
}
|
||||
|
||||
export async function getReviewByStatus(
|
||||
projectId: number,
|
||||
memberId: number,
|
||||
|
@ -2,7 +2,8 @@ import { useState } from 'react';
|
||||
import { useParams, Link } from 'react-router-dom';
|
||||
import Slider from 'react-slick';
|
||||
import useReviewDetailQuery from '@/queries/reviews/useReviewDetailQuery';
|
||||
import useUpdateReviewStatusQuery from '@/queries/reviews/useUpdateReviewStatusQuery';
|
||||
import useApproveReviewQuery from '@/queries/reviews/useApproveReviewQuery';
|
||||
import useRejectReviewQuery from '@/queries/reviews/useRejectReviewQuery';
|
||||
import useAuthStore from '@/stores/useAuthStore';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import 'slick-carousel/slick/slick.css';
|
||||
@ -20,38 +21,24 @@ export default function ReviewDetail(): JSX.Element {
|
||||
|
||||
const { data: reviewDetail } = useReviewDetailQuery(Number(projectId), Number(reviewId), memberId);
|
||||
|
||||
const updateReviewStatus = useUpdateReviewStatusQuery();
|
||||
const approveReviewMutation = useApproveReviewQuery({ projectId: Number(projectId), reviewId: Number(reviewId) });
|
||||
const rejectReviewMutation = useRejectReviewQuery({ projectId: Number(projectId), reviewId: Number(reviewId) });
|
||||
|
||||
const [activeTab, setActiveTab] = useState<'content' | 'images'>('content');
|
||||
const [isReviewed, setIsReviewed] = useState(
|
||||
reviewDetail?.reviewStatus === 'APPROVED' || reviewDetail?.reviewStatus === 'REJECTED'
|
||||
);
|
||||
|
||||
const handleApprove = () => {
|
||||
updateReviewStatus.mutate(
|
||||
{
|
||||
projectId: Number(projectId),
|
||||
reviewId: Number(reviewId),
|
||||
memberId,
|
||||
reviewStatus: 'APPROVED',
|
||||
},
|
||||
{
|
||||
onSuccess: () => setIsReviewed(true),
|
||||
}
|
||||
);
|
||||
approveReviewMutation.mutate(undefined, {
|
||||
onSuccess: () => setIsReviewed(true),
|
||||
});
|
||||
};
|
||||
|
||||
const handleReject = () => {
|
||||
updateReviewStatus.mutate(
|
||||
{
|
||||
projectId: Number(projectId),
|
||||
reviewId: Number(reviewId),
|
||||
memberId,
|
||||
reviewStatus: 'REJECTED',
|
||||
},
|
||||
{
|
||||
onSuccess: () => setIsReviewed(true),
|
||||
}
|
||||
);
|
||||
rejectReviewMutation.mutate(undefined, {
|
||||
onSuccess: () => setIsReviewed(true),
|
||||
});
|
||||
};
|
||||
|
||||
const settings = {
|
||||
@ -144,7 +131,7 @@ export default function ReviewDetail(): JSX.Element {
|
||||
variant="default"
|
||||
onClick={handleApprove}
|
||||
>
|
||||
승인
|
||||
{'승인'}
|
||||
</Button>
|
||||
)}
|
||||
{reviewDetail.reviewStatus !== 'REJECTED' && (
|
||||
@ -152,7 +139,7 @@ export default function ReviewDetail(): JSX.Element {
|
||||
variant="destructive"
|
||||
onClick={handleReject}
|
||||
>
|
||||
거부
|
||||
{'거부'}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user