"use client" import * as React from "react" import { type DataTableRowAction } from "@/types/table" import { type ColumnDef } from "@tanstack/react-table" import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" import { Checkbox } from "@/components/ui/checkbox" import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuShortcut, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu" import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip" import { formatDate} from "@/lib/utils" import { DataTableColumnHeaderSimple } from "@/components/data-table/data-table-column-simple-header" import { ExtendedLoginSession } from "../validation" import { Eye, Shield, LogOut, Ellipsis } from "lucide-react" 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, }, { id: "사용자 정보", header: "사용자 정보", columns: [ { accessorKey: "userEmail", header: ({ column }) => ( ), cell: ({ row }) => (
{row.getValue("userEmail")} {row.original.userName}
), }, ], }, { id: "세션 정보", header: "세션 정보", columns: [ { accessorKey: "loginAt", header: ({ column }) => ( ), cell: ({ row }) => { const date = row.getValue("loginAt") as Date return (
{formatDate(date, "KR")}
{formatDate(date, "KR")}
) }, }, { accessorKey: "logoutAt", header: ({ column }) => ( ), cell: ({ row }) => { const date = row.getValue("logoutAt") as Date | null if (!date) { return - } return (
{formatDate(date, "KR")}
{formatDate(date, "KR")}
) }, }, { accessorKey: "sessionDuration", header: ({ column }) => ( ), cell: ({ row }) => { const duration = row.getValue("sessionDuration") as number | null if (!duration) { return - } const hours = Math.floor(duration / 60) const minutes = Math.floor(duration % 60) if (hours > 0) { return `${hours}시간 ${minutes}분` } return `${minutes}분` }, }, ], }, { id: "인증 및 보안", header: "인증 및 보안", columns: [ { accessorKey: "authMethod", header: ({ column }) => ( ), cell: ({ row }) => { const authMethod = row.getValue("authMethod") as string const variants = { otp: "default", email: "secondary", sgips: "outline", saml: "destructive", } as const return ( {authMethod.toUpperCase()} ) }, }, { accessorKey: "ipAddress", header: ({ column }) => ( ), cell: ({ row }) => ( {row.getValue("ipAddress")} ), }, { accessorKey: "isCurrentlyActive", header: ({ column }) => ( ), cell: ({ row }) => { const isActive = row.getValue("isCurrentlyActive") as boolean return ( {isActive ? "활성" : "비활성"} ) }, }, ], }, // { // id: "actions", // cell: function Cell({ row }) { // const session = row.original // return ( // // // // // // setRowAction({ type: "view", row })} // > // // setRowAction({ type: "viewSecurity", row })} // > // // {session.isCurrentlyActive && ( // setRowAction({ type: "forceLogout", row })} // className="text-red-600" // > // // )} // // // ) // }, // enableSorting: false, // enableHiding: false, // }, ] }