develop #9
@@ -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<HTMLInputElement>(null);
|
||||
@@ -116,12 +118,15 @@ function MonitoringReviewActions({
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
<input ref={fileInputRef} type="file" className="hidden" onChange={(event) => void upload(event.target.files?.[0])} />
|
||||
<ActionButton icon="upload" disabled={!canUpload || uploadMutation.isPending} onClick={() => fileInputRef.current?.click()}>파일 업로드</ActionButton>
|
||||
<ActionButton disabled={!userId || !uploadFileName || originalMutation.isPending} onClick={downloadOriginal}>원본</ActionButton>
|
||||
<ActionButton disabled={!userId || !pdfFileName || pdfMutation.isPending} onClick={downloadPdf}>PDF</ActionButton>
|
||||
<ActionButton icon="preview" disabled={!userId || !pdfFileName} onClick={previewPdf}>미리보기</ActionButton>
|
||||
<div>
|
||||
<div className="grid grid-cols-2 gap-2">
|
||||
<input ref={fileInputRef} type="file" className="hidden" onChange={(event) => void upload(event.target.files?.[0])} />
|
||||
<ActionButton icon="upload" disabled={!canUpload || uploadMutation.isPending} onClick={() => fileInputRef.current?.click()}>파일 업로드</ActionButton>
|
||||
<ActionButton disabled={!userId || !uploadFileName || originalMutation.isPending} onClick={downloadOriginal}>원본</ActionButton>
|
||||
<ActionButton disabled={getReviewPdfDisabled(userId, pdfFileName, pdfConvert) || pdfMutation.isPending} onClick={downloadPdf}>{getReviewPdfStatusLabel(pdfConvert)}</ActionButton>
|
||||
<ActionButton icon="preview" disabled={getReviewPdfDisabled(userId, pdfFileName, pdfConvert)} onClick={previewPdf}>미리보기</ActionButton>
|
||||
</div>
|
||||
<span className="text-xs text-red-500">* 파일 크기 및 형식에 따라 PDF 변환이 최대 5분까지 소요됩니다.</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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({
|
||||
</>
|
||||
)}
|
||||
<FileActionButton icon="download" disabled={!userId || !uploadFileName || originalMutation.isPending} onClick={downloadOriginal}>원본</FileActionButton>
|
||||
<FileActionButton icon="download" disabled={!userId || !pdfFileName || pdfMutation.isPending} onClick={downloadPdf}>PDF</FileActionButton>
|
||||
<FileActionButton icon="preview" disabled={!userId || !pdfFileName} onClick={previewPdf}>미리보기</FileActionButton>
|
||||
<FileActionButton icon="download" disabled={getReviewPdfDisabled(userId, pdfFileName, pdfConvert) || pdfMutation.isPending} onClick={downloadPdf}>{getReviewPdfStatusLabel(pdfConvert)}</FileActionButton>
|
||||
<FileActionButton icon="preview" disabled={getReviewPdfDisabled(userId, pdfFileName, pdfConvert)} onClick={previewPdf}>미리보기</FileActionButton>
|
||||
<span className="text-xs text-red-500">* 파일 크기 및 형식에 따라 PDF 변환이 최대 5분까지 소요됩니다.</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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`;
|
||||
|
||||
|
||||
@@ -117,6 +117,15 @@ export type PerformanceMonitoringVisit = {
|
||||
gpsRaw: Record<string, unknown>;
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user