From 9da494b0e3bbe7b513521d0915510fe9ee376b8b Mon Sep 17 00:00:00 2001 From: dujinkim Date: Mon, 21 Jul 2025 07:19:52 +0000 Subject: (대표님, 최겸) 작업사항 - 이메일 템플릿, 메일링, 기술영업 요구사항 반영 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../table/template-table-columns.tsx | 296 +++++++++++++++++++++ 1 file changed, 296 insertions(+) create mode 100644 lib/email-template/table/template-table-columns.tsx (limited to 'lib/email-template/table/template-table-columns.tsx') diff --git a/lib/email-template/table/template-table-columns.tsx b/lib/email-template/table/template-table-columns.tsx new file mode 100644 index 00000000..d20739cc --- /dev/null +++ b/lib/email-template/table/template-table-columns.tsx @@ -0,0 +1,296 @@ +"use client" + +import * as React from "react" +import { type ColumnDef } from "@tanstack/react-table" +import { ArrowUpDown, Copy, MoreHorizontal, Edit, Trash, Eye } from "lucide-react" +import Link from "next/link" + +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 { type TemplateListView } from "@/db/schema" +import { type DataTableRowAction } from "@/types/table" +import { DataTableColumnHeaderSimple } from "@/components/data-table/data-table-column-simple-header" +import { getCategoryDisplayName, getCategoryVariant } 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" + /> + ), + enableSorting: false, + enableHiding: false, + }, + + // 템플릿 이름 컬럼 (클릭 시 세부 페이지로) + { + accessorKey: "name", + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const template = row.original + return ( +
+ + {template.name} + + {template.description && ( +
+ {template.description} +
+ )} +
+ ) + }, + enableSorting: true, + enableHiding: false, + size:200 + }, + + { + accessorKey: "subject", + header: ({ column }) => ( + + ), + cell: ({ getValue }) => { + const subject = getValue() as string + return ( +
+ {subject} +
+ ) + }, + enableSorting: true, + size:250 + }, + + // Slug 컬럼 + { + accessorKey: "slug", + header: ({ column }) => ( + + ), + cell: ({ getValue }) => { + const slug = getValue() as string + return ( +
+ {slug} +
+ ) + }, + enableSorting: true, + size:120 + + }, + + // 카테고리 컬럼 + { + accessorKey: "category", + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const category = row.original.category + const displayName = getCategoryDisplayName(category) + const variant = getCategoryVariant(category) + + return ( + + {displayName} + + ) + }, + enableSorting: true, + filterFn: (row, id, value) => { + return value.includes(row.getValue(id)) + }, + size:120 + + }, + + // 변수 개수 컬럼 + { + accessorKey: "variableCount", + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const variableCount = row.original.variableCount + const requiredCount = row.original.requiredVariableCount + + return ( +
+
{variableCount}
+ {requiredCount > 0 && ( +
+ 필수: {requiredCount} +
+ )} +
+ ) + }, + enableSorting: true, + size:80 + + }, + + // 버전 컬럼 + { + accessorKey: "version", + header: ({ column }) => ( + + ), + cell: ({ getValue }) => { + const version = getValue() as number + return ( +
+ + v{version} + +
+ ) + }, + enableSorting: true, + size:80 + + }, + + // 생성일 컬럼 + { + accessorKey: "createdAt", + header: ({ column }) => ( + + ), + cell: ({ cell }) => { + const date = cell.getValue() as Date + return ( +
+ {formatDate(date)} +
+ ) + }, + enableSorting: true, + size:200 + + }, + + // 수정일 컬럼 + { + accessorKey: "updatedAt", + header: ({ column }) => ( + + ), + cell: ({ cell }) => { + const date = cell.getValue() as Date + return ( +
+ {formatDate(date)} +
+ ) + }, + enableSorting: true, + size:200 + + }, + + // Actions 컬럼 + { + id: "actions", + cell: ({ row }) => { + const template = row.original + + return ( + + + + + + + + + + { + setRowAction({ type: "update", row }) + }} + > + + + { + setRowAction({ type: "duplicate", row }) + }} + > + + + + + { + setRowAction({ type: "delete", row }) + }} + className="text-destructive focus:text-destructive" + > + + + + ) + }, + enableSorting: false, + enableHiding: false, + size:80 + + }, + ] +} \ No newline at end of file -- cgit v1.2.3