diff options
Diffstat (limited to 'lib/tech-vendors/table/tech-vendors-table-columns.tsx')
| -rw-r--r-- | lib/tech-vendors/table/tech-vendors-table-columns.tsx | 117 |
1 files changed, 70 insertions, 47 deletions
diff --git a/lib/tech-vendors/table/tech-vendors-table-columns.tsx b/lib/tech-vendors/table/tech-vendors-table-columns.tsx index 69396c99..052794ce 100644 --- a/lib/tech-vendors/table/tech-vendors-table-columns.tsx +++ b/lib/tech-vendors/table/tech-vendors-table-columns.tsx @@ -225,6 +225,25 @@ export function getColumns({ setRowAction, router, openItemsDialog }: GetColumns className: "bg-gray-100 text-gray-800 border-gray-300", iconColor: "text-gray-600" }; + + case "PENDING_INVITE": + return { + variant: "default", + className: "bg-blue-100 text-blue-800 border-blue-300", + iconColor: "text-blue-600" + }; + case "INVITED": + return { + variant: "default", + className: "bg-green-100 text-green-800 border-green-300", + iconColor: "text-green-600" + }; + case "QUOTE_COMPARISON": + return { + variant: "default", + className: "bg-purple-100 text-purple-800 border-purple-300", + iconColor: "text-purple-600" + }; case "BLACKLISTED": return { variant: "destructive", @@ -246,7 +265,9 @@ export function getColumns({ setRowAction, router, openItemsDialog }: GetColumns "ACTIVE": "활성 상태", "INACTIVE": "비활성 상태", "BLACKLISTED": "거래 금지", - "PENDING_REVIEW": "비교 견적" + "PENDING_INVITE": "초대 대기", + "INVITED": "초대 완료", + "QUOTE_COMPARISON": "견적 비교" }; return statusMap[status] || status; @@ -269,56 +290,58 @@ export function getColumns({ setRowAction, router, openItemsDialog }: GetColumns ); } // TechVendorType 컬럼을 badge로 표시 - // if (cfg.id === "techVendorType") { - // const techVendorType = row.original.techVendorType as string; + if (cfg.id === "techVendorType") { + const techVendorType = row.original.techVendorType as string | null | undefined; - // // 벤더 타입 파싱 개선 - // let types: string[] = []; - // if (!techVendorType) { - // types = []; - // } else if (techVendorType.startsWith('[') && techVendorType.endsWith(']')) { - // // JSON 배열 형태 - // try { - // const parsed = JSON.parse(techVendorType); - // types = Array.isArray(parsed) ? parsed.filter(Boolean) : [techVendorType]; - // } catch { - // types = [techVendorType]; - // } - // } else if (techVendorType.includes(',')) { - // // 콤마로 구분된 문자열 - // types = techVendorType.split(',').map(t => t.trim()).filter(Boolean); - // } else { - // // 단일 문자열 - // types = [techVendorType.trim()].filter(Boolean); - // } - // // 벤더 타입 정렬 - 조선 > 해양top > 해양hull 순 - // const typeOrder = ["조선", "해양top", "해양hull"]; - // types.sort((a, b) => { - // const indexA = typeOrder.indexOf(a); - // const indexB = typeOrder.indexOf(b); - - // // 정의된 순서에 있는 경우 우선순위 적용 - // if (indexA !== -1 && indexB !== -1) { - // return indexA - indexB; - // } - // return a.localeCompare(b); - // }); - // return ( - // <div className="flex flex-wrap gap-1"> - // {types.length > 0 ? types.map((type, index) => ( - // <Badge key={`${type}-${index}`} variant="secondary" className="text-xs"> - // {type} - // </Badge> - // )) : ( - // <span className="text-muted-foreground">-</span> - // )} - // </div> - // ); - // } + // 벤더 타입 파싱 개선 - null/undefined 안전 처리 + let types: string[] = []; + if (!techVendorType) { + types = []; + } else if (techVendorType.startsWith('[') && techVendorType.endsWith(']')) { + // JSON 배열 형태 + try { + const parsed = JSON.parse(techVendorType); + types = Array.isArray(parsed) ? parsed.filter(Boolean) : [techVendorType]; + } catch { + types = [techVendorType]; + } + } else if (techVendorType.includes(',')) { + // 콤마로 구분된 문자열 + types = techVendorType.split(',').map(t => t.trim()).filter(Boolean); + } else { + // 단일 문자열 + types = [techVendorType.trim()].filter(Boolean); + } + + // 벤더 타입 정렬 - 조선 > 해양top > 해양hull 순 + const typeOrder = ["조선", "해양top", "해양hull"]; + types.sort((a, b) => { + const indexA = typeOrder.indexOf(a); + const indexB = typeOrder.indexOf(b); + + // 정의된 순서에 있는 경우 우선순위 적용 + if (indexA !== -1 && indexB !== -1) { + return indexA - indexB; + } + return a.localeCompare(b); + }); + + return ( + <div className="flex flex-wrap gap-1"> + {types.length > 0 ? types.map((type, index) => ( + <Badge key={`${type}-${index}`} variant="secondary" className="text-xs"> + {type} + </Badge> + )) : ( + <span className="text-muted-foreground">-</span> + )} + </div> + ); + } // 날짜 컬럼 포맷팅 if (cfg.type === "date" && cell.getValue()) { - return formatDate(cell.getValue() as Date, "KR"); + return formatDate(cell.getValue() as Date); } return cell.getValue(); |
