From fb20768fa881841d3f80d12a276a9445feb6f514 Mon Sep 17 00:00:00 2001 From: joonhoekim <26rote@gmail.com> Date: Tue, 30 Sep 2025 05:04:33 +0000 Subject: (고건) 이메일 템플릿 정보 수정/복제 기능 에러 수정 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../table/template-table-columns.tsx | 187 +++++++++------------ 1 file changed, 84 insertions(+), 103 deletions(-) (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 index a678a20a..9c3e69c2 100644 --- a/lib/email-template/table/template-table-columns.tsx +++ b/lib/email-template/table/template-table-columns.tsx @@ -1,41 +1,46 @@ -"use client" +'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 */ +import { Badge } from '@/components/ui/badge'; +import { Button } from '@/components/ui/button'; +import { Checkbox } from '@/components/ui/checkbox'; +import { Copy, Eye, MoreHorizontal, Trash } from 'lucide-react'; +import { DataTableColumnHeaderSimple } from '@/components/data-table/data-table-column-simple-header'; 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" +} from '@/components/ui/dropdown-menu'; +import { formatDate } from '@/lib/utils'; +import { getCategoryDisplayName, getCategoryVariant } from '../validations'; +import Link from 'next/link'; +import { type ColumnDef } from '@tanstack/react-table'; +import { type Dispatch, type SetStateAction } from 'react'; +import { type DataTableRowAction } from '@/types/table'; +import { type TemplateListView } from '@/db/schema'; + +// ---------------------------------------------------------------------------------------------------- +/* TYPES */ interface GetColumnsProps { - setRowAction: React.Dispatch | null>> + setRowAction: Dispatch | null>>; } +// ---------------------------------------------------------------------------------------------------- + +/* FUNCTION FOR GETTING COLUMNS SETTING */ export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef[] { return [ - // 체크박스 컬럼 + // [1] Checkbox Column { - id: "select", + id: 'select', header: ({ table }) => ( table.toggleAllPageRowsSelected(!!value)} aria-label="Select all" @@ -53,10 +58,9 @@ export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef ( ), @@ -80,34 +84,33 @@ export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef ( - - ), - cell: ({ getValue }) => { - const subject = getValue() as string - return ( -
- {subject} -
- ) - }, - enableSorting: true, - size:250 + accessorKey: 'subject', + header: ({ column }) => ( + + ), + cell: ({ getValue }) => { + const subject = getValue() as string; + return ( +
+ {subject} +
+ ) }, - - // Slug 컬럼 + enableSorting: true, + size: 250, + }, + // [4] Slug Column { - accessorKey: "slug", + accessorKey: 'slug', header: ({ column }) => ( ), cell: ({ getValue }) => { - const slug = getValue() as string + const slug = getValue() as string; return (
{slug} @@ -115,44 +118,40 @@ export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef ( ), cell: ({ row }) => { - const category = row.original.category - const displayName = getCategoryDisplayName(category) - const variant = getCategoryVariant(category) + 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)) + return value.includes(row.getValue(id)); }, - size:120 - + enableSorting: true, + size: 120, }, - - // 변수 개수 컬럼 + // [6] Variable Count Column { - accessorKey: "variableCount", + accessorKey: 'variableCount', header: ({ column }) => ( ), cell: ({ row }) => { - const variableCount = row.original.variableCount - const requiredCount = row.original.requiredVariableCount + const variableCount = row.original.variableCount; + const requiredCount = row.original.requiredVariableCount; return (
@@ -163,21 +162,20 @@ export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef )}
- ) + ); }, enableSorting: true, - size:80 - + size: 80, }, - - // 버전 컬럼 + // [7] Version Column { - accessorKey: "version", + accessorKey: 'version', header: ({ column }) => ( ), cell: ({ getValue }) => { - const version = getValue() as number + const version = getValue() as number; + return (
@@ -187,18 +185,17 @@ export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef ( ), cell: ({ cell }) => { - const date = cell.getValue() as Date + const date = cell.getValue() as Date; + return (
{formatDate(date)} @@ -206,18 +203,17 @@ export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef ( ), cell: ({ cell }) => { - const date = cell.getValue() as Date + const date = cell.getValue() as Date; + return (
{formatDate(date)} @@ -225,15 +221,13 @@ export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef { - const template = row.original + const template = row.original; return ( @@ -253,30 +247,18 @@ export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef - - {/* { - setRowAction({ type: "update", row }) - }} - > - */} - { - setRowAction({ type: "duplicate", row }) + setRowAction({ type: 'duplicate', row }) }} > - - { - setRowAction({ type: "delete", row }) + setRowAction({ type: 'delete', row }) }} className="text-destructive focus:text-destructive" > @@ -290,7 +272,6 @@ export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef