260623_01_ENH: 엑셀 다운로드를 제외한 기능 완성
This commit is contained in:
@@ -15,5 +15,5 @@ export const qk = {
|
||||
|
||||
monitoringEvidence: (performanceId: number, userId: string) => ["monitoring", "evidence", performanceId, userId] as const,
|
||||
|
||||
review: (performanceId: number, reviewType: number) => ["review", performanceId, reviewType] as const,
|
||||
review: (performanceId: number, reviewType: number, userId?: string) => ["review", performanceId, reviewType, userId] as const,
|
||||
} as const;
|
||||
|
||||
@@ -5,11 +5,11 @@ import {nextApi} from "@/lib/http-client";
|
||||
import {qk} from "@/query/key/keys";
|
||||
import {PerformanceReview} from "@/types/gwcf";
|
||||
|
||||
export function useReviewFileQuery(performanceId: number, reviewType: number, enabled: boolean = true) {
|
||||
export function useReviewFileQuery(performanceId: number, reviewType: number, userId?: string, enabled: boolean = true) {
|
||||
return useQuery({
|
||||
queryKey: qk.review(performanceId, reviewType),
|
||||
queryFn: () => nextApi.get<PerformanceReview>(`/review/${performanceId}/${reviewType}`),
|
||||
enabled: enabled && performanceId > 0 && reviewType > 0,
|
||||
queryKey: qk.review(performanceId, reviewType, userId),
|
||||
queryFn: () => nextApi.get<PerformanceReview>(`/review/${performanceId}/${reviewType}/${encodeURIComponent(userId ?? "")}`),
|
||||
enabled: enabled && performanceId > 0 && reviewType > 0 && Boolean(userId),
|
||||
staleTime: 0,
|
||||
refetchOnMount: "always",
|
||||
});
|
||||
@@ -25,7 +25,7 @@ export function useUploadReviewFileMutation() {
|
||||
return nextApi.postForm<PerformanceReview>(`/review/${performanceId}/${reviewType}`, formData);
|
||||
},
|
||||
onSuccess: (_res, {performanceId, reviewType}) => {
|
||||
qc.invalidateQueries({ queryKey: qk.review(performanceId, reviewType) });
|
||||
qc.invalidateQueries({ queryKey: ["review", performanceId, reviewType] });
|
||||
qc.invalidateQueries({ queryKey: qk.performance(performanceId) });
|
||||
qc.invalidateQueries({ queryKey: ["performance", "list"] });
|
||||
},
|
||||
@@ -34,15 +34,15 @@ export function useUploadReviewFileMutation() {
|
||||
|
||||
export function useDownloadReviewOriginalMutation() {
|
||||
return useMutation({
|
||||
mutationFn: ({performanceId, reviewType}: {performanceId: number; reviewType: number}) =>
|
||||
nextApi.get<ArrayBuffer>(`/review/download/${performanceId}/${reviewType}`, {expectBinary: true}),
|
||||
mutationFn: ({performanceId, reviewType, userId}: {performanceId: number; reviewType: number; userId: string}) =>
|
||||
nextApi.get<ArrayBuffer>(`/review/download/${performanceId}/${reviewType}/${encodeURIComponent(userId)}`, {expectBinary: true}),
|
||||
});
|
||||
}
|
||||
|
||||
export function useDownloadReviewPdfMutation() {
|
||||
return useMutation({
|
||||
mutationFn: ({performanceId, reviewType}: {performanceId: number; reviewType: number}) =>
|
||||
nextApi.get<ArrayBuffer>(`/review/pdf/${performanceId}/${reviewType}`, {expectBinary: true}),
|
||||
mutationFn: ({performanceId, reviewType, userId}: {performanceId: number; reviewType: number; userId: string}) =>
|
||||
nextApi.get<ArrayBuffer>(`/review/pdf/${performanceId}/${reviewType}/${encodeURIComponent(userId)}`, {expectBinary: true}),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -50,8 +50,9 @@ export function useStartWrittenReviewMutation() {
|
||||
const qc = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (performanceId: number) => nextApi.post<void>(`/review/start/${performanceId}`),
|
||||
onSuccess: (_res, performanceId) => {
|
||||
mutationFn: ({performanceId, userId}: {performanceId: number; userId: string}) =>
|
||||
nextApi.post<void>(`/review/start/${performanceId}/${encodeURIComponent(userId)}`),
|
||||
onSuccess: (_res, {performanceId}) => {
|
||||
qc.invalidateQueries({ queryKey: qk.performance(performanceId) });
|
||||
qc.invalidateQueries({ queryKey: ["performance", "list"] });
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user