260708_02_ENH: pdf 변환에 대한 공지 및 변환 상태 표기
This commit is contained in:
@@ -5,7 +5,7 @@ import {Download, ImageIcon, ScanSearch, Upload} from "lucide-react";
|
|||||||
import {Button} from "@/components/ui/button";
|
import {Button} from "@/components/ui/button";
|
||||||
import {Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle} from "@/components/ui/dialog";
|
import {Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle} from "@/components/ui/dialog";
|
||||||
import {StatusPill} from "@/components/gwcf/StatusPill";
|
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 {CodeGroup} from "@/query/code";
|
||||||
import {getCodeLabel} from "@/lib/gwcf/view";
|
import {getCodeLabel} from "@/lib/gwcf/view";
|
||||||
import {
|
import {
|
||||||
@@ -28,8 +28,8 @@ import {
|
|||||||
downloadBlob,
|
downloadBlob,
|
||||||
downloadFromUrl,
|
downloadFromUrl,
|
||||||
getEvidenceZipDownloadName,
|
getEvidenceZipDownloadName,
|
||||||
getReviewOriginalDownloadName,
|
getReviewOriginalDownloadName, getReviewPdfDisabled,
|
||||||
getReviewPdfDownloadName,
|
getReviewPdfDownloadName, getReviewPdfStatusLabel,
|
||||||
openPreviewWindow,
|
openPreviewWindow,
|
||||||
} from "@/lib/gwcf/file";
|
} from "@/lib/gwcf/file";
|
||||||
import {PERFORMANCE_FIELD_LABELS} from "@/lib/gwcf/field-labels";
|
import {PERFORMANCE_FIELD_LABELS} from "@/lib/gwcf/field-labels";
|
||||||
@@ -73,6 +73,7 @@ function MonitoringReviewActions({
|
|||||||
reviewType,
|
reviewType,
|
||||||
userId,
|
userId,
|
||||||
uploadFileName,
|
uploadFileName,
|
||||||
|
pdfConvert,
|
||||||
pdfFileName,
|
pdfFileName,
|
||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
canUpload: boolean;
|
canUpload: boolean;
|
||||||
@@ -80,6 +81,7 @@ function MonitoringReviewActions({
|
|||||||
reviewType: number;
|
reviewType: number;
|
||||||
userId?: string;
|
userId?: string;
|
||||||
uploadFileName?: string;
|
uploadFileName?: string;
|
||||||
|
pdfConvert?: PdfConvertStatus;
|
||||||
pdfFileName?: string;
|
pdfFileName?: string;
|
||||||
}>) {
|
}>) {
|
||||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||||
@@ -116,12 +118,15 @@ function MonitoringReviewActions({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="grid grid-cols-2 gap-2">
|
<div>
|
||||||
<input ref={fileInputRef} type="file" className="hidden" onChange={(event) => void upload(event.target.files?.[0])} />
|
<div className="grid grid-cols-2 gap-2">
|
||||||
<ActionButton icon="upload" disabled={!canUpload || uploadMutation.isPending} onClick={() => fileInputRef.current?.click()}>파일 업로드</ActionButton>
|
<input ref={fileInputRef} type="file" className="hidden" onChange={(event) => void upload(event.target.files?.[0])} />
|
||||||
<ActionButton disabled={!userId || !uploadFileName || originalMutation.isPending} onClick={downloadOriginal}>원본</ActionButton>
|
<ActionButton icon="upload" disabled={!canUpload || uploadMutation.isPending} onClick={() => fileInputRef.current?.click()}>파일 업로드</ActionButton>
|
||||||
<ActionButton disabled={!userId || !pdfFileName || pdfMutation.isPending} onClick={downloadPdf}>PDF</ActionButton>
|
<ActionButton disabled={!userId || !uploadFileName || originalMutation.isPending} onClick={downloadOriginal}>원본</ActionButton>
|
||||||
<ActionButton icon="preview" disabled={!userId || !pdfFileName} onClick={previewPdf}>미리보기</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>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,15 @@ import {Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle} from "@/
|
|||||||
import {DatePicker} from "@/components/common/DatePicker";
|
import {DatePicker} from "@/components/common/DatePicker";
|
||||||
import {FilterSelect} from "@/components/gwcf/FilterSelect";
|
import {FilterSelect} from "@/components/gwcf/FilterSelect";
|
||||||
import {StatusPill} from "@/components/gwcf/StatusPill";
|
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 {CodeGroup} from "@/query/code";
|
||||||
import {getCodeLabel, getDetailValue, ROLE} from "@/lib/gwcf/view";
|
import {getCodeLabel, getDetailValue, ROLE} from "@/lib/gwcf/view";
|
||||||
import {
|
import {
|
||||||
@@ -37,8 +45,8 @@ import {
|
|||||||
downloadBlob,
|
downloadBlob,
|
||||||
downloadFromUrl,
|
downloadFromUrl,
|
||||||
getEvidenceZipDownloadName,
|
getEvidenceZipDownloadName,
|
||||||
getReviewOriginalDownloadName,
|
getReviewOriginalDownloadName, getReviewPdfDisabled,
|
||||||
getReviewPdfDownloadName,
|
getReviewPdfDownloadName, getReviewPdfStatusLabel,
|
||||||
openPreviewWindow,
|
openPreviewWindow,
|
||||||
openWrittenReviewWindow,
|
openWrittenReviewWindow,
|
||||||
} from "@/lib/gwcf/file";
|
} from "@/lib/gwcf/file";
|
||||||
@@ -116,6 +124,7 @@ function ReviewFileActions({
|
|||||||
userId,
|
userId,
|
||||||
uploadFileName,
|
uploadFileName,
|
||||||
pdfFileName,
|
pdfFileName,
|
||||||
|
pdfConvert,
|
||||||
canUpload,
|
canUpload,
|
||||||
canEdit,
|
canEdit,
|
||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
@@ -124,6 +133,7 @@ function ReviewFileActions({
|
|||||||
userId?: string;
|
userId?: string;
|
||||||
uploadFileName?: string;
|
uploadFileName?: string;
|
||||||
pdfFileName?: string;
|
pdfFileName?: string;
|
||||||
|
pdfConvert?: PdfConvertStatus
|
||||||
canUpload: boolean;
|
canUpload: boolean;
|
||||||
canEdit: 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 || !uploadFileName || originalMutation.isPending} onClick={downloadOriginal}>원본</FileActionButton>
|
||||||
<FileActionButton icon="download" disabled={!userId || !pdfFileName || pdfMutation.isPending} onClick={downloadPdf}>PDF</FileActionButton>
|
<FileActionButton icon="download" disabled={getReviewPdfDisabled(userId, pdfFileName, pdfConvert) || pdfMutation.isPending} onClick={downloadPdf}>{getReviewPdfStatusLabel(pdfConvert)}</FileActionButton>
|
||||||
<FileActionButton icon="preview" disabled={!userId || !pdfFileName} onClick={previewPdf}>미리보기</FileActionButton>
|
<FileActionButton icon="preview" disabled={getReviewPdfDisabled(userId, pdfFileName, pdfConvert)} onClick={previewPdf}>미리보기</FileActionButton>
|
||||||
|
<span className="text-xs text-red-500">* 파일 크기 및 형식에 따라 PDF 변환이 최대 5분까지 소요됩니다.</span>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import {downloadFile} from "@/lib/utils";
|
import {downloadFile} from "@/lib/utils";
|
||||||
import {buildWrittenReviewLink} from "@/config/gwcf.config";
|
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}_/;
|
const REVIEW_TIMESTAMP_PREFIX = /^\d{4}-\d{2}-\d{2}_\d{6}_/;
|
||||||
|
|
||||||
@@ -74,6 +75,27 @@ export const getReviewPdfDownloadName = (
|
|||||||
pdfFileName?: string
|
pdfFileName?: string
|
||||||
) => removeTimestampPrefix(pdfFileName) || `review-pdf-${performanceId}-${reviewType}.pdf`;
|
) => 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) =>
|
export const getEvidenceZipDownloadName = (performanceId: number, userId: string) =>
|
||||||
`도착 증빙_${performanceId}_${userId}.zip`;
|
`도착 증빙_${performanceId}_${userId}.zip`;
|
||||||
|
|
||||||
|
|||||||
@@ -117,6 +117,15 @@ export type PerformanceMonitoringVisit = {
|
|||||||
gpsRaw: Record<string, unknown>;
|
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 = {
|
export type PerformanceReview = {
|
||||||
performanceId: number;
|
performanceId: number;
|
||||||
reviewType: number;
|
reviewType: number;
|
||||||
@@ -124,7 +133,7 @@ export type PerformanceReview = {
|
|||||||
reviewDt: string;
|
reviewDt: string;
|
||||||
reviewStatus: number;
|
reviewStatus: number;
|
||||||
uploadFileName: string;
|
uploadFileName: string;
|
||||||
pdfConvert: boolean;
|
pdfConvert: PdfConvertStatus;
|
||||||
pdfFileName: string;
|
pdfFileName: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user