diff options
| author | joonhoekim <26rote@gmail.com> | 2025-11-17 15:42:29 +0900 |
|---|---|---|
| committer | joonhoekim <26rote@gmail.com> | 2025-11-17 15:42:29 +0900 |
| commit | b9f575f6110faabc7b062f84bf491d69d88a10a5 (patch) | |
| tree | 23babc36a1131a861bcb9fbae7fed7314e6ce7e7 /lib/swp/table/swp-inbox-table-columns.tsx | |
| parent | 85d32a79dcf0f7047406039363baa2e06b859ddd (diff) | |
(김준회) swp: GetExternalInboxList를 메인 테이블로 변경
Diffstat (limited to 'lib/swp/table/swp-inbox-table-columns.tsx')
| -rw-r--r-- | lib/swp/table/swp-inbox-table-columns.tsx | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/lib/swp/table/swp-inbox-table-columns.tsx b/lib/swp/table/swp-inbox-table-columns.tsx new file mode 100644 index 00000000..bd740ca4 --- /dev/null +++ b/lib/swp/table/swp-inbox-table-columns.tsx @@ -0,0 +1,129 @@ +"use client"; + +import React from "react"; +import { ColumnDef } from "@tanstack/react-table"; +import { Badge } from "@/components/ui/badge"; +import type { SwpFileApiResponse } from "@/lib/swp/api-client"; + +export const swpInboxDocumentColumns: ColumnDef<SwpFileApiResponse>[] = [ + { + accessorKey: "STAT_NM", + header: "최신 리비전의 최신 파일 상태", + cell: ({ row }) => { + const statNm = row.original.STAT_NM; + const stat = row.original.STAT; + const displayStatus = statNm || stat || "-"; + + if (!stat) return displayStatus; + + // STAT 코드 기반 색상 결정 + const color = + stat === "SCW03" || stat === "SCW08" ? "bg-green-100 text-green-800" : // Complete, Checked + stat === "SCW02" ? "bg-blue-100 text-blue-800" : // Processing + stat === "SCW01" ? "bg-yellow-100 text-yellow-800" : // Standby + stat === "SCW04" || stat === "SCW05" || stat === "SCW06" ? "bg-red-100 text-red-800" : // Reject, Error Zip, Error Meta + stat === "SCW07" ? "bg-purple-100 text-purple-800" : // Send for Eng Verification + stat === "SCW09" ? "bg-gray-100 text-gray-800" : // Cancelled + stat === "SCW00" ? "bg-orange-100 text-orange-800" : // Upload + "bg-gray-100 text-gray-800"; // 기타 + + return ( + <Badge variant="outline" className={color}> + {displayStatus} + </Badge> + ); + }, + size: 120, + }, + { + accessorKey: "OWN_DOC_NO", + header: "OWN_DOC_NO", + cell: ({ row }) => ( + <div className="font-mono text-sm">{row.original.OWN_DOC_NO || "-"}</div> + ), + size: 250, + }, + { + accessorKey: "FILE_NM", + header: "파일명", + cell: ({ row }) => ( + <div className="max-w-md truncate" title={row.original.FILE_NM}> + {row.original.FILE_NM} + </div> + ), + size: 300, + }, + { + accessorKey: "STAGE", + header: "스테이지", + cell: ({ row }) => { + const stage = row.original.STAGE; + if (!stage) return "-"; + + 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} + </Badge> + ); + }, + size: 80, + }, + { + accessorKey: "REV_NO", + header: "REV", + cell: ({ row }) => row.original.REV_NO || "-", + size: 80, + }, + { + accessorKey: "ACTV_NO", + header: "Activity", + cell: ({ row }) => { + const actvNo = row.original.ACTV_NO; + if (!actvNo) return <span className="text-muted-foreground">-</span>; + return <div className="font-mono text-xs">{actvNo}</div>; + }, + size: 120, + }, + { + accessorKey: "FILE_SZ", + header: "파일 크기", + cell: ({ row }) => { + const size = row.original.FILE_SZ; + if (!size) return "-"; + const bytes = parseInt(size); + if (isNaN(bytes)) return size; + + if (bytes < 1024) return `${bytes} B`; + if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`; + if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`; + return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`; + }, + size: 100, + }, + { + accessorKey: "CRTE_DTM", + header: "생성일시", + cell: ({ row }) => { + const date = row.original.CRTE_DTM; + if (!date) return "-"; + try { + return new Date(date).toLocaleString("ko-KR", { + year: "numeric", + month: "2-digit", + day: "2-digit", + hour: "2-digit", + minute: "2-digit", + }); + } catch { + return date; + } + }, + size: 150, + }, +]; + |
