From e0dfb55c5457aec489fc084c4567e791b4c65eb1 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Wed, 26 Mar 2025 00:37:41 +0000 Subject: 3/25 까지의 대표님 작업사항 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../table/doc-table-column.tsx | 202 +++++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100644 lib/vendor-document-list/table/doc-table-column.tsx (limited to 'lib/vendor-document-list/table/doc-table-column.tsx') diff --git a/lib/vendor-document-list/table/doc-table-column.tsx b/lib/vendor-document-list/table/doc-table-column.tsx new file mode 100644 index 00000000..30fb06b0 --- /dev/null +++ b/lib/vendor-document-list/table/doc-table-column.tsx @@ -0,0 +1,202 @@ +"use client" + +import * as React from "react" +import { ColumnDef } from "@tanstack/react-table" +import { formatDate, formatDateTime } 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 { DocumentStagesView } from "@/db/schema/vendorDocu" +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuRadioGroup, + DropdownMenuRadioItem, + DropdownMenuSeparator, + DropdownMenuShortcut, + DropdownMenuSub, + DropdownMenuSubContent, + DropdownMenuSubTrigger, + DropdownMenuTrigger, +} from "@/components/ui/dropdown-menu" +import { Button } from "@/components/ui/button" +import { Ellipsis } from "lucide-react" +import { Badge } from "@/components/ui/badge" + +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: "docNumber", + header: ({ column }) => ( + + ), + cell: ({ row }) =>
{row.getValue("docNumber")}
, + meta: { + excelHeader: "Doc Number" + }, + enableResizing: true, + minSize: 50, + size: 100, + }, + { + accessorKey: "title", + header: ({ column }) => ( + + ), + cell: ({ row }) =>
{row.getValue("title")}
, + meta: { + excelHeader: "Doc title" + }, + enableResizing: true, + minSize: 100, + size: 160, + }, + + { + accessorKey: "stageCount", + header: ({ column }) => ( + + ), + cell: ({ row }) =>
{row.getValue("stageCount")}
, + meta: { + excelHeader: "Stage Count" + }, + enableResizing: true, + minSize: 50, + size: 50, + }, + { + accessorKey: "stageList", + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const stageNames = row.getValue("stageList") as string[] | null + + if (!stageNames || stageNames.length === 0) { + return No stages + } + + return ( +
+ {stageNames.map((stageName, idx) => ( + + {stageName} + + ))} +
+ ) + }, + enableResizing: true, + minSize: 120, + size: 120, + }, + { + accessorKey: "status", + header: ({ column }) => ( + + ), + cell: ({ row }) =>
{row.getValue("status")}
, + meta: { + excelHeader: "status" + }, + enableResizing: true, + minSize: 60, + size: 60, + }, + { + accessorKey: "createdAt", + header: ({ column }) => ( + + ), + cell: ({ cell }) => formatDateTime(cell.getValue() as Date), + meta: { + excelHeader: "created At" + }, + enableResizing: true, + minSize: 120, + size: 120, + }, + { + accessorKey: "updatedAt", + header: ({ column }) => ( + + ), + cell: ({ cell }) => formatDateTime(cell.getValue() as Date), + meta: { + excelHeader: "updated At" + }, + enableResizing: true, + minSize: 120, + size: 120, + }, + { + id: "actions", + enableHiding: false, + cell: function Cell({ row }) { + const [isUpdatePending, startUpdateTransition] = React.useTransition() + + return ( + + + + + + setRowAction({ row, type: "update" })} + > + Edit + + + setRowAction({ row, type: "delete" })} + > + Delete + ⌘⌫ + + + + ) + }, + size: 40, + } + ] +} \ No newline at end of file -- cgit v1.2.3