From 53ad72732f781e6c6d5ddb3776ea47aec010af8e Mon Sep 17 00:00:00 2001 From: dujinkim Date: Mon, 4 Aug 2025 09:39:21 +0000 Subject: (최겸) PQ/실사 수정 및 개발 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pq/pq-criteria/pq-table-column.tsx | 232 +++++++++++++++++++++++++++++++++ 1 file changed, 232 insertions(+) create mode 100644 lib/pq/pq-criteria/pq-table-column.tsx (limited to 'lib/pq/pq-criteria/pq-table-column.tsx') diff --git a/lib/pq/pq-criteria/pq-table-column.tsx b/lib/pq/pq-criteria/pq-table-column.tsx new file mode 100644 index 00000000..924d80c4 --- /dev/null +++ b/lib/pq/pq-criteria/pq-table-column.tsx @@ -0,0 +1,232 @@ +"use client" + +import * as React from "react" +import { ColumnDef } from "@tanstack/react-table" +import { formatDate } from "@/lib/utils" +import { Checkbox } from "@/components/ui/checkbox" +import { DataTableColumnHeaderSimple } from "@/components/data-table/data-table-column-simple-header" +import { DataTableRowAction } from "@/types/table" +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuShortcut, + DropdownMenuTrigger, +} from "@/components/ui/dropdown-menu" +import { Button } from "@/components/ui/button" +import { Ellipsis } from "lucide-react" +import { Badge } from "@/components/ui/badge" +import { PqCriterias } from "@/db/schema/pq" + +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: "groupName", + header: ({ column }) => ( + + ), + cell: ({ row }) =>
{row.getValue("groupName")}
, + meta: { + excelHeader: "Group Name" + }, + enableResizing: true, + minSize: 60, + size: 100, + }, + { + accessorKey: "subGroupName", + header: ({ column }) => ( + + ), + cell: ({ row }) =>
{row.getValue("subGroupName") || "-"}
, + meta: { + excelHeader: "Sub Group Name" + }, + enableResizing: true, + minSize: 60, + size: 100, + }, + { + accessorKey: "code", + header: ({ column }) => ( + + ), + cell: ({ row }) =>
{row.getValue("code")}
, + meta: { + excelHeader: "Code" + }, + enableResizing: true, + minSize: 50, + size: 100, + }, + { + accessorKey: "checkPoint", + header: ({ column }) => ( + + ), + cell: ({ row }) =>
{row.getValue("checkPoint")}
, + meta: { + excelHeader: "Check Point" + }, + enableResizing: true, + minSize: 180, + size: 180, + }, + + { + accessorKey: "description", + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const text = row.getValue("description") as string + return ( +
+ {text} +
+ ) + }, + meta: { + excelHeader: "Description" + }, + enableResizing: true, + minSize: 180, + size: 180, + }, + // { + // accessorKey: "remarks", + // header: ({ column }) => ( + // + // ), + // cell: ({ row }) => { + // const text = row.getValue("remarks") as string + // return ( + //
+ // {text || "-"} + //
+ // ) + // }, + // meta: { + // excelHeader: "Remarks" + // }, + // enableResizing: true, + // minSize: 180, + // size: 180, + // }, + { + accessorKey: "inputFormat", + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const format = row.getValue("inputFormat") as string + const formatLabels = { + TEXT: "텍스트", + FILE: "파일", + EMAIL: "이메일", + PHONE: "전화번호", + NUMBER: "숫자", + "TEXT_FILE": "텍스트 + 파일" + } + return ( + + {formatLabels[format as keyof typeof formatLabels] || format} + + ) + }, + meta: { + excelHeader: "Input Format" + }, + enableResizing: true, + minSize: 100, + size: 120, + }, + + { + accessorKey: "createdAt", + header: ({ column }) => ( + + ), + cell: ({ cell }) => formatDate(cell.getValue() as Date, "ko-KR"), + enableResizing: true, + minSize: 180, + size: 180, + }, + { + accessorKey: "updatedAt", + header: ({ column }) => ( + + ), + cell: ({ cell }) => formatDate(cell.getValue() as Date, "ko-KR"), + enableResizing: true, + minSize: 180, + size: 180, + }, + { + id: "actions", + enableHiding: false, + cell: function Cell({ row }) { + return ( + + + + + + setRowAction({ row, type: "update" })} + > + Edit + + + setRowAction({ row, type: "delete" })} + > + Delete + ⌘⌫ + + + + ) + }, + size: 40, + } + ] +} \ No newline at end of file -- cgit v1.2.3