diff options
Diffstat (limited to 'lib/swp/table/swp-table-columns.tsx')
| -rw-r--r-- | lib/swp/table/swp-table-columns.tsx | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/lib/swp/table/swp-table-columns.tsx b/lib/swp/table/swp-table-columns.tsx index 9954ab73..9aecea96 100644 --- a/lib/swp/table/swp-table-columns.tsx +++ b/lib/swp/table/swp-table-columns.tsx @@ -7,7 +7,6 @@ import { ChevronDown, ChevronRight, FileIcon, Download, Loader2 } from "lucide-r import { formatDistanceToNow } from "date-fns"; import { ko } from "date-fns/locale"; import type { SwpDocumentWithStats } from "../actions"; -import { downloadSwpFile } from "../actions"; import { useState } from "react"; import { toast } from "sonner"; @@ -29,6 +28,28 @@ export const swpDocumentColumns: ColumnDef<SwpDocumentWithStats>[] = [ size: 50, }, { + accessorKey: "LTST_ACTV_STAT", + header: "상태 (최신 액티비티)", + cell: ({ row }) => { + const status = row.original.LTST_ACTV_STAT; + if (!status) return "-"; + + // 상태에 따른 색상 설정 (필요에 따라 조정 가능) + const color = + status === "Complete" ? "bg-green-100 text-green-800" : + status === "In Progress" ? "bg-blue-100 text-blue-800" : + status === "Pending" ? "bg-yellow-100 text-yellow-800" : + "bg-gray-100 text-gray-800"; + + return ( + <Badge variant="outline" className={color}> + {status} + </Badge> + ); + }, + size: 100, + }, + { accessorKey: "DOC_NO", header: "문서번호", cell: ({ row }) => ( @@ -90,12 +111,12 @@ export const swpDocumentColumns: ColumnDef<SwpDocumentWithStats>[] = [ cell: ({ row }) => { const stage = row.original.STAGE; if (!stage) return "-"; - - const color = + + const color = stage === "IFC" ? "bg-green-100 text-green-800" : stage === "IFA" ? "bg-blue-100 text-blue-800" : "bg-gray-100 text-gray-800"; - + return ( <Badge variant="outline" className={color}> {stage} @@ -123,28 +144,6 @@ export const swpDocumentColumns: ColumnDef<SwpDocumentWithStats>[] = [ size: 100, }, { - accessorKey: "LTST_ACTV_STAT", - header: "상태 (최신 액티비티)", - cell: ({ row }) => { - const status = row.original.LTST_ACTV_STAT; - if (!status) return "-"; - - // 상태에 따른 색상 설정 (필요에 따라 조정 가능) - const color = - status === "Complete" ? "bg-green-100 text-green-800" : - status === "In Progress" ? "bg-blue-100 text-blue-800" : - status === "Pending" ? "bg-yellow-100 text-yellow-800" : - "bg-gray-100 text-gray-800"; - - return ( - <Badge variant="outline" className={color}> - {status} - </Badge> - ); - }, - size: 100, - }, - { accessorKey: "last_synced_at", header: "동기화", cell: ({ row }) => ( @@ -399,26 +398,27 @@ function DownloadButton({ fileId, fileName }: DownloadButtonProps) { try { setIsDownloading(true); - // 서버 액션 호출 - const result = await downloadSwpFile(fileId); + // API Route 호출 (바이너리 직접 전송) + const response = await fetch(`/api/swp/download/${fileId}`); - if (!result.success || !result.data) { - toast.error(result.error || "파일 다운로드 실패"); + if (!response.ok) { + const errorData = await response.json().catch(() => ({ error: "다운로드 실패" })); + toast.error(errorData.error || "파일 다운로드 실패"); return; } // Blob 생성 및 다운로드 - const blob = new Blob([result.data as unknown as BlobPart], { type: result.mimeType }); + const blob = await response.blob(); const url = window.URL.createObjectURL(blob); const link = document.createElement("a"); link.href = url; - link.download = result.fileName || fileName; + link.download = fileName; document.body.appendChild(link); link.click(); document.body.removeChild(link); window.URL.revokeObjectURL(url); - toast.success(`파일 다운로드 완료: ${result.fileName}`); + toast.success(`파일 다운로드 완료: ${fileName}`); } catch (error) { console.error("다운로드 오류:", error); toast.error("파일 다운로드 중 오류가 발생했습니다."); |
