From a070f833d132e6370311c0bbdad03beb51d595df Mon Sep 17 00:00:00 2001 From: joonhoekim <26rote@gmail.com> Date: Wed, 15 Oct 2025 21:38:21 +0900 Subject: (김준회) 이메일 화이트리스트 (SMS 우회) 기능 추가 및 기존 로그인 과정 통합 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../table/whitelist-table-columns.tsx | 208 +++++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 lib/email-whitelist/table/whitelist-table-columns.tsx (limited to 'lib/email-whitelist/table/whitelist-table-columns.tsx') diff --git a/lib/email-whitelist/table/whitelist-table-columns.tsx b/lib/email-whitelist/table/whitelist-table-columns.tsx new file mode 100644 index 00000000..2533d863 --- /dev/null +++ b/lib/email-whitelist/table/whitelist-table-columns.tsx @@ -0,0 +1,208 @@ +'use client'; + +/* IMPORT */ +import { Badge } from '@/components/ui/badge'; +import { Button } from '@/components/ui/button'; +import { Checkbox } from '@/components/ui/checkbox'; +import { MoreHorizontal, Trash, Pencil } 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 { formatDate } from '@/lib/utils'; +import { type ColumnDef } from '@tanstack/react-table'; +import { type Dispatch, type SetStateAction } from 'react'; +import { type DataTableRowAction } from '@/types/table'; +import { type EmailWhitelist } from '../service'; + +// ---------------------------------------------------------------------------------------------------- + +/* TYPES */ +interface GetColumnsProps { + setRowAction: Dispatch | null>>; +} + +// ---------------------------------------------------------------------------------------------------- + +/* FUNCTION FOR GETTING COLUMNS SETTING */ +export function getColumns({ setRowAction }: GetColumnsProps): ColumnDef[] { + return [ + // [1] Checkbox Column + { + 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, + }, + + // [2] ID Column + { + accessorKey: 'id', + header: ({ column }) => ( + + ), + cell: ({ row }) =>
{row.getValue('id')}
, + enableSorting: false, + enableHiding: false, + size: 80, + }, + + // [3] Email/Domain Column + { + accessorKey: 'displayValue', + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const displayValue = row.getValue('displayValue') as string; + const isEmail = displayValue.includes('@'); + + return ( +
+ + {isEmail ? displayValue : `@${displayValue}`} + +
+ ); + }, + enableSorting: false, + size: 220, + }, + + // [4] Description Column + { + accessorKey: 'description', + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const description = row.getValue('description') as string; + return ( +
+ {description || '-'} +
+ ); + }, + enableSorting: false, + size: 200, + }, + + // [5] Created At Column + { + accessorKey: 'createdAt', + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const date = row.getValue('createdAt') as Date; + return
{formatDate(date, "KR")}
; + }, + enableSorting: false, + size: 120, + }, + + // [6] Created By Column + { + accessorKey: 'createdByName', + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const name = row.getValue('createdByName') as string; + return
{name || '-'}
; + }, + enableSorting: false, + size: 100, + }, + + // [7] Updated At Column + { + accessorKey: 'updatedAt', + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const date = row.getValue('updatedAt') as Date; + return
{formatDate(date, "KR")}
; + }, + enableSorting: false, + size: 120, + }, + + // [8] Updated By Column + { + accessorKey: 'updatedByName', + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const name = row.getValue('updatedByName') as string; + return
{name || '-'}
; + }, + enableSorting: false, + size: 100, + }, + + // [9] Actions Column + { + id: 'actions', + cell: ({ row }) => ( + + + + + + setRowAction({ row, type: 'update' })} + > + + 수정 + + + setRowAction({ row, type: 'delete' })} + className="text-destructive" + > + + 삭제 + + + + ), + enableSorting: false, + enableHiding: false, + enableResizing: false, + size: 80, + minSize: 80, + maxSize: 80, + }, + ]; +} -- cgit v1.2.3