diff options
Diffstat (limited to 'lib/vendor-document-list/plant/upload')
| -rw-r--r-- | lib/vendor-document-list/plant/upload/columns.tsx | 13 | ||||
| -rw-r--r-- | lib/vendor-document-list/plant/upload/table.tsx | 25 |
2 files changed, 37 insertions, 1 deletions
diff --git a/lib/vendor-document-list/plant/upload/columns.tsx b/lib/vendor-document-list/plant/upload/columns.tsx index c0f17afc..01fc61df 100644 --- a/lib/vendor-document-list/plant/upload/columns.tsx +++ b/lib/vendor-document-list/plant/upload/columns.tsx @@ -25,7 +25,8 @@ import { CheckCircle2, XCircle, AlertCircle, - Clock + Clock, + Download } from "lucide-react" interface GetColumnsProps { @@ -360,6 +361,16 @@ export function getColumns({ </> )} + + {/* ✅ 커버 페이지 다운로드 */} + <DropdownMenuItem + onSelect={() => setRowAction({ row, type: "downloadCover" })} + className="gap-2" + > + <Download className="h-4 w-4" /> + Download Cover Page + </DropdownMenuItem> + <DropdownMenuSeparator /> <DropdownMenuItem diff --git a/lib/vendor-document-list/plant/upload/table.tsx b/lib/vendor-document-list/plant/upload/table.tsx index 92507900..84b04092 100644 --- a/lib/vendor-document-list/plant/upload/table.tsx +++ b/lib/vendor-document-list/plant/upload/table.tsx @@ -20,6 +20,7 @@ import { ProjectFilter } from "./components/project-filter" import { SingleUploadDialog } from "./components/single-upload-dialog" import { HistoryDialog } from "./components/history-dialog" import { ViewSubmissionDialog } from "./components/view-submission-dialog" +import { toast } from "sonner" interface StageSubmissionsTableProps { promises: Promise<[ @@ -159,6 +160,30 @@ export function StageSubmissionsTable({ promises, selectedProjectId }: StageSubm columnResizeMode: "onEnd", }) + + React.useEffect(() => { + if (!rowAction) return; + + const { type, row } = rowAction; + + if (type === "downloadCover") { + // 2) 서버에서 생성 후 다운로드 (예: API 호출) + (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"); + } catch (e) { + toast.error("커버 페이지 생성에 실패했습니다."); + console.error(e); + } finally { + setRowAction(null); + } + })(); + } + }, [rowAction, setRowAction]); + return ( <> <DataTable table={table}> |
