From 2650b7c0bb0ea12b68a58c0439f72d61df04b2f1 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Fri, 25 Jul 2025 07:51:15 +0000 Subject: (대표님) 정기평가 대상, 미들웨어 수정, nextauth 토큰 처리 개선, GTC 등 (최겸) 기술영업 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../possible-items/possible-items-columns.tsx | 470 ++++++++++++--------- 1 file changed, 265 insertions(+), 205 deletions(-) (limited to 'lib/tech-vendors/possible-items/possible-items-columns.tsx') diff --git a/lib/tech-vendors/possible-items/possible-items-columns.tsx b/lib/tech-vendors/possible-items/possible-items-columns.tsx index ef48c5b5..252dae9b 100644 --- a/lib/tech-vendors/possible-items/possible-items-columns.tsx +++ b/lib/tech-vendors/possible-items/possible-items-columns.tsx @@ -1,206 +1,266 @@ -"use client" - -import * as React from "react" -import { type DataTableRowAction } from "@/types/table" -import { type ColumnDef } from "@tanstack/react-table" -import { Ellipsis } from "lucide-react" - -import { formatDate } from "@/lib/utils" -import { Badge } from "@/components/ui/badge" -import { Button } from "@/components/ui/button" -import { Checkbox } from "@/components/ui/checkbox" -import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuShortcut, - DropdownMenuTrigger, -} from "@/components/ui/dropdown-menu" - -import { DataTableColumnHeaderSimple } from "@/components/data-table/data-table-column-simple-header" -import type { TechVendorPossibleItem } from "../validations" - -interface GetColumnsProps { - setRowAction: React.Dispatch | null>>; -} - -export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef[] { - return [ - // 선택 체크박스 - { - id: "select", - header: ({ table }) => ( - table.toggleAllPageRowsSelected(!!value)} - aria-label="Select all" - className="translate-y-0.5" - /> - ), - cell: ({ row }) => ( - row.toggleSelected(!!value)} - aria-label="Select row" - className="translate-y-0.5" - /> - ), - size: 40, - enableSorting: false, - enableHiding: false, - }, - - // 아이템 코드 - { - accessorKey: "itemCode", - header: ({ column }) => ( - - ), - cell: ({ row }) => ( -
- {row.getValue("itemCode")} -
- ), - size: 150, - }, - - // 공종 - { - accessorKey: "workType", - header: ({ column }) => ( - - ), - cell: ({ row }) => { - const workType = row.getValue("workType") as string | null - return workType ? ( - - {workType} - - ) : ( - - - ) - }, - size: 100, - }, - - // 아이템명 - { - accessorKey: "itemList", - header: ({ column }) => ( - - ), - cell: ({ row }) => { - const itemList = row.getValue("itemList") as string | null - return ( -
- {itemList || -} -
- ) - }, - size: 300, - }, - - // 선종 (조선용) - { - accessorKey: "shipTypes", - header: ({ column }) => ( - - ), - cell: ({ row }) => { - const shipTypes = row.getValue("shipTypes") as string | null - return shipTypes ? ( - - {shipTypes} - - ) : ( - - - ) - }, - size: 120, - }, - - // 서브아이템 (해양용) - { - accessorKey: "subItemList", - header: ({ column }) => ( - - ), - cell: ({ row }) => { - const subItemList = row.getValue("subItemList") as string | null - return ( -
- {subItemList || -} -
- ) - }, - size: 200, - }, - - // 등록일 - { - accessorKey: "createdAt", - header: ({ column }) => ( - - ), - cell: ({ row }) => { - const date = row.getValue("createdAt") as Date - return ( -
- {formatDate(date)} -
- ) - }, - size: 120, - }, - - // 수정일 - { - accessorKey: "updatedAt", - header: ({ column }) => ( - - ), - cell: ({ row }) => { - const date = row.getValue("updatedAt") as Date - return ( -
- {formatDate(date)} -
- ) - }, - size: 120, - }, - - // 액션 메뉴 - { - id: "actions", - enableHiding: false, - cell: function Cell({ row }) { - return ( - - - - - - setRowAction({ row, type: "delete" })} - > - 삭제 - ⌘⌫ - - - - ) - }, - size: 40, - }, - ] +"use client" + +import * as React from "react" +import { type DataTableRowAction } from "@/types/table" +import { type ColumnDef } from "@tanstack/react-table" +import { Ellipsis } from "lucide-react" + +import { formatDate } from "@/lib/utils" +import { Badge } from "@/components/ui/badge" +import { Button } from "@/components/ui/button" +import { Checkbox } from "@/components/ui/checkbox" +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuShortcut, + DropdownMenuTrigger, +} from "@/components/ui/dropdown-menu" + +import { DataTableColumnHeaderSimple } from "@/components/data-table/data-table-column-simple-header" +import type { TechVendorPossibleItem } from "../validations" + +interface GetColumnsProps { + setRowAction: React.Dispatch | null>>; +} + +export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef[] { + return [ + // 선택 체크박스 + { + id: "select", + header: ({ table }) => ( + table.toggleAllPageRowsSelected(!!value)} + aria-label="Select all" + className="translate-y-0.5" + /> + ), + cell: ({ row }) => ( + row.toggleSelected(!!value)} + aria-label="Select row" + className="translate-y-0.5" + /> + ), + size: 40, + enableSorting: false, + enableHiding: false, + }, + + // 아이템 코드 + { + accessorKey: "itemCode", + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const itemCode = row.getValue("itemCode") as string | undefined + return ( +
+ {itemCode || -} +
+ ) + }, + size: 150, + }, + + // // 타입 + // { + // accessorKey: "techVendorType", + // header: ({ column }) => ( + // + // ), + // cell: ({ row }) => { + // const techVendorType = row.getValue("techVendorType") as string | undefined + + // // 벤더 타입 파싱 개선 - 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 ( + //
+ // {types.length > 0 ? types.map((type, index) => ( + // + // {type} + // + // )) : ( + // - + // )} + //
+ // ) + // }, + // size: 120, + // }, + + // 공종 + { + accessorKey: "workType", + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const workType = row.getValue("workType") as string | null + return workType ? ( + + {workType} + + ) : ( + - + ) + }, + size: 100, + }, + + // 아이템명 + { + accessorKey: "itemList", + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const itemList = row.getValue("itemList") as string | null + return ( +
+ {itemList || -} +
+ ) + }, + size: 300, + }, + + // 선종 (조선용) + { + accessorKey: "shipTypes", + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const shipTypes = row.getValue("shipTypes") as string | null + return shipTypes ? ( + + {shipTypes} + + ) : ( + - + ) + }, + size: 120, + }, + + // 서브아이템 (해양용) + { + accessorKey: "subItemList", + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const subItemList = row.getValue("subItemList") as string | null + return ( +
+ {subItemList || -} +
+ ) + }, + size: 200, + }, + + // 등록일 + { + accessorKey: "createdAt", + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const date = row.getValue("createdAt") as Date + return ( +
+ {formatDate(date, "ko-KR")} +
+ ) + }, + size: 120, + }, + + // 수정일 + { + accessorKey: "updatedAt", + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const date = row.getValue("updatedAt") as Date + return ( +
+ {formatDate(date, "ko-KR")} +
+ ) + }, + size: 120, + }, + + // 액션 메뉴 + { + id: "actions", + enableHiding: false, + cell: function Cell({ row }) { + return ( + + + + + + setRowAction({ row, type: "delete" })} + > + 삭제 + ⌘⌫ + + + + ) + }, + size: 40, + }, + ] } \ No newline at end of file -- cgit v1.2.3