diff --git a/src/components/dialog/MonitoringPerformanceDetailDialog.tsx b/src/components/dialog/MonitoringPerformanceDetailDialog.tsx index 2666a85..b061f6c 100644 --- a/src/components/dialog/MonitoringPerformanceDetailDialog.tsx +++ b/src/components/dialog/MonitoringPerformanceDetailDialog.tsx @@ -5,7 +5,7 @@ import {Download, ImageIcon, ScanSearch, Upload} from "lucide-react"; import {Button} from "@/components/ui/button"; import {Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle} from "@/components/ui/dialog"; import {StatusPill} from "@/components/gwcf/StatusPill"; -import {Code, PerformanceFull} from "@/types/gwcf"; +import {Code, PDF_CONVERT_STATUS, PdfConvertStatus, PerformanceFull} from "@/types/gwcf"; import {CodeGroup} from "@/query/code"; import {getCodeLabel} from "@/lib/gwcf/view"; import { @@ -28,8 +28,8 @@ import { downloadBlob, downloadFromUrl, getEvidenceZipDownloadName, - getReviewOriginalDownloadName, - getReviewPdfDownloadName, + getReviewOriginalDownloadName, getReviewPdfDisabled, + getReviewPdfDownloadName, getReviewPdfStatusLabel, openPreviewWindow, } from "@/lib/gwcf/file"; import {PERFORMANCE_FIELD_LABELS} from "@/lib/gwcf/field-labels"; @@ -73,6 +73,7 @@ function MonitoringReviewActions({ reviewType, userId, uploadFileName, + pdfConvert, pdfFileName, }: Readonly<{ canUpload: boolean; @@ -80,6 +81,7 @@ function MonitoringReviewActions({ reviewType: number; userId?: string; uploadFileName?: string; + pdfConvert?: PdfConvertStatus; pdfFileName?: string; }>) { const fileInputRef = useRef(null); @@ -116,12 +118,15 @@ function MonitoringReviewActions({ }; return ( -
- void upload(event.target.files?.[0])} /> - fileInputRef.current?.click()}>파일 업로드 - 원본 - PDF - 미리보기 +
+
+ void upload(event.target.files?.[0])} /> + fileInputRef.current?.click()}>파일 업로드 + 원본 + {getReviewPdfStatusLabel(pdfConvert)} + 미리보기 +
+ * 파일 크기 및 형식에 따라 PDF 변환이 최대 5분까지 소요됩니다.
); } diff --git a/src/components/dialog/PerformanceDetailDialog.tsx b/src/components/dialog/PerformanceDetailDialog.tsx index caff98c..581cf61 100644 --- a/src/components/dialog/PerformanceDetailDialog.tsx +++ b/src/components/dialog/PerformanceDetailDialog.tsx @@ -8,7 +8,15 @@ import {Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle} from "@/ import {DatePicker} from "@/components/common/DatePicker"; import {FilterSelect} from "@/components/gwcf/FilterSelect"; import {StatusPill} from "@/components/gwcf/StatusPill"; -import {Code, PerformanceCompact, PerformanceFull, PerformanceMonitoringSchedule, PerformanceStaff, UserFull} from "@/types/gwcf"; +import { + Code, + PdfConvertStatus, + PerformanceCompact, + PerformanceFull, + PerformanceMonitoringSchedule, + PerformanceStaff, + UserFull +} from "@/types/gwcf"; import {CodeGroup} from "@/query/code"; import {getCodeLabel, getDetailValue, ROLE} from "@/lib/gwcf/view"; import { @@ -37,8 +45,8 @@ import { downloadBlob, downloadFromUrl, getEvidenceZipDownloadName, - getReviewOriginalDownloadName, - getReviewPdfDownloadName, + getReviewOriginalDownloadName, getReviewPdfDisabled, + getReviewPdfDownloadName, getReviewPdfStatusLabel, openPreviewWindow, openWrittenReviewWindow, } from "@/lib/gwcf/file"; @@ -116,6 +124,7 @@ function ReviewFileActions({ userId, uploadFileName, pdfFileName, + pdfConvert, canUpload, canEdit, }: Readonly<{ @@ -124,6 +133,7 @@ function ReviewFileActions({ userId?: string; uploadFileName?: string; pdfFileName?: string; + pdfConvert?: PdfConvertStatus canUpload: boolean; canEdit: boolean; }>) { @@ -176,8 +186,9 @@ function ReviewFileActions({ )} 원본 - PDF - 미리보기 + {getReviewPdfStatusLabel(pdfConvert)} + 미리보기 + * 파일 크기 및 형식에 따라 PDF 변환이 최대 5분까지 소요됩니다.
); } diff --git a/src/lib/gwcf/file.ts b/src/lib/gwcf/file.ts index 854ac45..e6cb233 100644 --- a/src/lib/gwcf/file.ts +++ b/src/lib/gwcf/file.ts @@ -1,5 +1,6 @@ import {downloadFile} from "@/lib/utils"; import {buildWrittenReviewLink} from "@/config/gwcf.config"; +import {PDF_CONVERT_STATUS, PdfConvertStatus} from "@/types/gwcf"; const REVIEW_TIMESTAMP_PREFIX = /^\d{4}-\d{2}-\d{2}_\d{6}_/; @@ -74,6 +75,27 @@ export const getReviewPdfDownloadName = ( pdfFileName?: string ) => removeTimestampPrefix(pdfFileName) || `review-pdf-${performanceId}-${reviewType}.pdf`; +export const getReviewPdfDisabled = ( + userId: string | undefined, + pdfFileName?: string, + pdfConvert?: PdfConvertStatus +) => !userId || !pdfFileName || pdfConvert !== PDF_CONVERT_STATUS.COMPLETED; + +export const getReviewPdfStatusLabel = ( + pdfConvert?: PdfConvertStatus +) => { + switch (pdfConvert) { + case PDF_CONVERT_STATUS.COMPLETED: + return "PDF"; + case PDF_CONVERT_STATUS.FAILED: + case PDF_CONVERT_STATUS.NOT_TARGET: + return "변환 실패"; + case PDF_CONVERT_STATUS.IN_PROGRESS: + default: + return "변환 중"; + } +} + export const getEvidenceZipDownloadName = (performanceId: number, userId: string) => `도착 증빙_${performanceId}_${userId}.zip`; diff --git a/src/types/gwcf.ts b/src/types/gwcf.ts index 236837f..5228cc3 100644 --- a/src/types/gwcf.ts +++ b/src/types/gwcf.ts @@ -117,6 +117,15 @@ export type PerformanceMonitoringVisit = { gpsRaw: Record; }; +export const PDF_CONVERT_STATUS = { + IN_PROGRESS: 0, + COMPLETED: 1, + NOT_TARGET: 8, + FAILED: 9, +} as const; + +export type PdfConvertStatus = typeof PDF_CONVERT_STATUS[keyof typeof PDF_CONVERT_STATUS]; + export type PerformanceReview = { performanceId: number; reviewType: number; @@ -124,7 +133,7 @@ export type PerformanceReview = { reviewDt: string; reviewStatus: number; uploadFileName: string; - pdfConvert: boolean; + pdfConvert: PdfConvertStatus; pdfFileName: string; };