"use client" import * as React from "react" import { type ColumnDef } from "@tanstack/react-table" import { ArrowUpDown, Copy, MoreHorizontal } from "lucide-react" import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" import { Checkbox } from "@/components/ui/checkbox" import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu" import { toast } from "sonner" import { formatDate } from "@/lib/utils" import { OcrRow } from "@/db/schema" import { type DataTableRowAction } from "@/types/table" import { DataTableColumnHeaderSimple } from "@/components/data-table/data-table-column-simple-header" 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" /> ), enableSorting: false, enableHiding: false, }, // Report No 컬럼 { accessorKey: "reportNo", header: ({ column }) => ( ), cell: ({ getValue }) => { const reportNo = getValue() as string return (
{/* */} {reportNo || "N/A"} {/* */}
) }, enableSorting: true, enableHiding: false, }, // No 컬럼 { accessorKey: "no", header: ({ column }) => ( ), cell: ({ getValue }) => { const no = getValue() as string return (
{no || "-"}
) }, enableSorting: true, }, // Identification No 컬럼 { accessorKey: "identificationNo", header: ({ column }) => ( ), cell: ({ getValue }) => { const identificationNo = getValue() as string return (
{identificationNo || "-"}
) }, enableSorting: true, }, // Tag No 컬럼 { accessorKey: "tagNo", header: ({ column }) => ( ), cell: ({ getValue }) => { const tagNo = getValue() as string return (
{tagNo || "-"}
) }, enableSorting: true, }, // Joint No 컬럼 { accessorKey: "jointNo", header: ({ column }) => ( ), cell: ({ getValue }) => { const jointNo = getValue() as string return (
{jointNo || "-"}
) }, enableSorting: true, }, // Joint Type 컬럼 { accessorKey: "jointType", header: ({ column }) => ( ), cell: ({ getValue }) => { const jointType = getValue() as string return ( {jointType || "N/A"} ) }, enableSorting: true, }, // Welding Date 컬럼 { accessorKey: "weldingDate", header: ({ column }) => ( ), cell: ({ getValue }) => { const weldingDate = getValue() as string return (
{weldingDate || "-"}
) }, enableSorting: true, }, // Confidence 컬럼 { accessorKey: "confidence", header: ({ column }) => ( ), cell: ({ getValue }) => { const confidence = parseFloat(getValue() as string) || 0 const percentage = Math.round(confidence * 100) let variant: "default" | "secondary" | "destructive" = "default" if (percentage < 70) variant = "destructive" else if (percentage < 90) variant = "secondary" return ( {percentage}% ) }, enableSorting: true, }, // Source Table 컬럼 // { // accessorKey: "sourceTable", // header: ({ column }) => ( // // ), // cell: ({ getValue }) => { // const sourceTable = getValue() as number // return ( //
// // T{sourceTable} // //
// ) // }, // enableSorting: true, // }, // // Source Row 컬럼 // { // accessorKey: "sourceRow", // header: ({ column }) => ( // // ), // cell: ({ getValue }) => { // const sourceRow = getValue() as number // return ( //
// {sourceRow} //
// ) // }, // enableSorting: true, // }, { accessorKey: "userName", header: ({ column }) => ( ), cell: ({ getValue }) => { const userName = getValue() as string return (
{userName || "-"}
) }, enableSorting: true, }, { accessorKey: "userEmail", header: ({ column }) => ( ), cell: ({ getValue }) => { const userEmail = getValue() as string return (
{userEmail || "-"}
) }, enableSorting: true, }, // Created At 컬럼 { accessorKey: "createdAt", header: ({ column }) => ( ), cell: ({ cell }) => { const date = cell.getValue() as Date return (
{formatDate(date)}
) }, enableSorting: true, }, // Actions 컬럼 { id: "actions", cell: ({ row }) => ( { setRowAction({ type: "update", row }) }} // className="text-destructive focus:text-destructive" > Update { setRowAction({ type: "delete", row }) }} className="text-destructive focus:text-destructive" > Delete ), enableSorting: false, enableHiding: false, }, ] }