From b54f6f03150dd78d86db62201b6386bf14b72394 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Wed, 15 Oct 2025 12:52:11 +0000 Subject: (대표님) 커버, 데이터룸, 파일매니저, 담당자할당 등 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/vendor-document-list/plant/upload/columns.tsx | 198 +++++++++++---------- lib/vendor-document-list/plant/upload/table.tsx | 37 +++- .../ship-all/enhanced-documents-table.tsx | 20 +-- 3 files changed, 141 insertions(+), 114 deletions(-) (limited to 'lib/vendor-document-list') diff --git a/lib/vendor-document-list/plant/upload/columns.tsx b/lib/vendor-document-list/plant/upload/columns.tsx index 01fc61df..9c2fe228 100644 --- a/lib/vendor-document-list/plant/upload/columns.tsx +++ b/lib/vendor-document-list/plant/upload/columns.tsx @@ -17,16 +17,16 @@ import { DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu" -import { - Ellipsis, - Upload, - Eye, - RefreshCw, - CheckCircle2, - XCircle, +import { + Ellipsis, + Upload, + Eye, + RefreshCw, + CheckCircle2, + XCircle, AlertCircle, Clock, - Download + Download } from "lucide-react" interface GetColumnsProps { @@ -109,7 +109,7 @@ export function getColumns({ const stageName = row.getValue("stageName") as string const stageStatus = row.original.stageStatus const stageOrder = row.original.stageOrder - + return (
@@ -119,12 +119,12 @@ export function getColumns({ {stageName}
{stageStatus && ( - @@ -145,9 +145,9 @@ export function getColumns({ const planDate = row.getValue("stagePlanDate") as Date | null const isOverdue = row.original.isOverdue const daysUntilDue = row.original.daysUntilDue - + if (!planDate) return - - + return (
@@ -187,7 +187,7 @@ export function getColumns({ const reviewStatus = row.original.latestReviewStatus const revisionNumber = row.original.latestRevisionNumber const revisionCode = row.original.latestRevisionCode - + if (!status) { return ( @@ -196,20 +196,20 @@ export function getColumns({ ) } - + return (
- {reviewStatus || status} - {revisionCode !== null &&( + {revisionCode !== null && (
{revisionCode}
@@ -229,7 +229,7 @@ export function getColumns({ const syncStatus = row.getValue("latestSyncStatus") as string | null const syncProgress = row.original.syncProgress const requiresSync = row.original.requiresSync - + if (!syncStatus || syncStatus === "pending") { if (requiresSync) { return ( @@ -241,15 +241,15 @@ export function getColumns({ } return - } - + return (
- @@ -274,9 +274,9 @@ export function getColumns({ cell: ({ row }) => { const totalFiles = row.getValue("totalFiles") as number const syncedFiles = row.original.syncedFilesCount - + if (!totalFiles) return 0 - + return (
{syncedFiles !== null && syncedFiles !== undefined ? ( @@ -297,7 +297,7 @@ export function getColumns({ // cell: ({ row }) => { // const vendorName = row.getValue("vendorName") as string // const vendorCode = row.original.vendorCode - + // return ( //
//
{vendorName}
@@ -309,82 +309,88 @@ export function getColumns({ // }, // size: 150, // }, - { - id: "actions", - enableHiding: false, - cell: function Cell({ row }) { - const requiresSubmission = row.original.requiresSubmission - const requiresSync = row.original.requiresSync - const latestSubmissionId = row.original.latestSubmissionId - - return ( - - - + + + {requiresSubmission && ( + setRowAction({ row, type: "upload" })} + className="gap-2" + > + + Upload Documents + + )} + + {latestSubmissionId && ( + <> + setRowAction({ row, type: "view" })} + className="gap-2" > - - - - - {requiresSubmission && ( + + View Submission + + + {requiresSync && ( setRowAction({ row, type: "upload" })} + onSelect={() => setRowAction({ row, type: "sync" })} className="gap-2" > - - Upload Documents + + Retry Sync )} - - {latestSubmissionId && ( - <> - setRowAction({ row, type: "view" })} - className="gap-2" - > - - View Submission - - - {requiresSync && ( - setRowAction({ row, type: "sync" })} - className="gap-2" - > - - Retry Sync - - )} - - )} - - - {/* ✅ 커버 페이지 다운로드 */} - setRowAction({ row, type: "downloadCover" })} - className="gap-2" - > - - Download Cover Page - + + )} + {/* ✅ 커버 페이지 다운로드 - projectCode가 있을 때만 표시 */} + {projectCode && ( + <> - setRowAction({ row, type: "history" })} + onSelect={() => setRowAction({ row, type: "downloadCover" })} className="gap-2" > - - View History + + Download Cover Page - - - ) - }, - size: 40, - } + + )} + + + + setRowAction({ row, type: "history" })} + className="gap-2" + > + + View History + + + + ) + }, + size: 40, +} ] } \ No newline at end of file diff --git a/lib/vendor-document-list/plant/upload/table.tsx b/lib/vendor-document-list/plant/upload/table.tsx index 84b04092..2247fc57 100644 --- a/lib/vendor-document-list/plant/upload/table.tsx +++ b/lib/vendor-document-list/plant/upload/table.tsx @@ -21,6 +21,7 @@ import { SingleUploadDialog } from "./components/single-upload-dialog" import { HistoryDialog } from "./components/history-dialog" import { ViewSubmissionDialog } from "./components/view-submission-dialog" import { toast } from "sonner" +import { quickDownload } from "@/lib/file-download" interface StageSubmissionsTableProps { promises: Promise<[ @@ -167,23 +168,43 @@ export function StageSubmissionsTable({ promises, selectedProjectId }: StageSubm const { type, row } = rowAction; if (type === "downloadCover") { - // 2) 서버에서 생성 후 다운로드 (예: API 호출) + const projectCode = row.original.projectCode; + const project = projects.find(p => p.code === projectCode); + + if (!project) { + toast.error("프로젝트 정보를 찾을 수 없습니다."); + setRowAction(null); + return; + } + (async () => { try { - const res = await fetch(`/api/stages/${row.original.stageId}/cover`, { method: "POST" }); - if (!res.ok) throw new Error("failed"); - const { fileUrl } = await res.json(); // 서버 응답: { fileUrl: string } - window.open(fileUrl, "_blank", "noopener,noreferrer"); + const res = await fetch(`/api/projects/${project.id}/cover`, { + method: "GET" + }); + + if (!res.ok) { + const error = await res.json(); + throw new Error(error.message || "커버 페이지를 가져올 수 없습니다"); + } + + const { fileUrl, fileName } = await res.json(); + + // quickDownload 사용 + quickDownload(fileUrl, fileName || `${projectCode}_cover.docx`); + + toast.success("커버 페이지 다운로드를 시작했습니다."); + } catch (e) { - toast.error("커버 페이지 생성에 실패했습니다."); + toast.error(e instanceof Error ? e.message : "커버 페이지 다운로드에 실패했습니다."); console.error(e); } finally { setRowAction(null); } })(); } - }, [rowAction, setRowAction]); - + }, [rowAction, setRowAction, projects]); + return ( <> diff --git a/lib/vendor-document-list/ship-all/enhanced-documents-table.tsx b/lib/vendor-document-list/ship-all/enhanced-documents-table.tsx index 255aa56c..b8b7542a 100644 --- a/lib/vendor-document-list/ship-all/enhanced-documents-table.tsx +++ b/lib/vendor-document-list/ship-all/enhanced-documents-table.tsx @@ -167,16 +167,16 @@ export function SimplifiedDocumentsTable({ label: "Second Actual Date", type: "date", }, - { - id: "issuedDate", - label: "Issue Date", - type: "date", - }, - { - id: "createdAt", - label: "Created Date", - type: "date", - }, + // { + // id: "issuedDate", + // label: "Issue Date", + // type: "date", + // }, + // { + // id: "createdAt", + // label: "Created Date", + // type: "date", + // }, { id: "updatedAt", label: "Updated Date", -- cgit v1.2.3