"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, }, ] }