"use client"; import { ColumnDef } from "@tanstack/react-table"; import { FileInfoItem } from "../actions"; import { Button } from "@/components/ui/button"; import { Download, Trash2 } from "lucide-react"; import { formatDolceDateTime } from "../utils/date-formatter"; interface FileListColumnsProps { onDownload: (file: FileInfoItem) => void; onDelete?: (file: FileInfoItem) => void; lng?: string; } export const createFileListColumns = ({ onDownload, onDelete, lng = "ko", }: FileListColumnsProps): ColumnDef[] => [ { accessorKey: "FileSeq", header: lng === "ko" ? "순번" : "No.", minSize: 80, cell: ({ row }) => { if (row.original.FileServerId === "LOCAL") { return
-
; } return
{row.getValue("FileSeq")}
; }, }, { accessorKey: "FileName", header: lng === "ko" ? "파일명" : "File Name", minSize: 300, cell: ({ row }) => { return
{row.getValue("FileName")}
; }, }, { accessorKey: "FileSize", header: lng === "ko" ? "파일크기" : "File Size", minSize: 100, cell: ({ row }) => { const size = parseInt(row.getValue("FileSize") as string); if (isNaN(size) || size === 0) return "-"; if (size < 1024) return `${size} B`; if (size < 1024 * 1024) return `${(size / 1024).toFixed(2)} KB`; return `${(size / (1024 * 1024)).toFixed(2)} MB`; }, }, { accessorKey: "CreateDt", header: lng === "ko" ? "생성일시" : "Created Date", minSize: 200, cell: ({ row }) => { const date = row.getValue("CreateDt") as string; return
{formatDolceDateTime(date)}
; }, }, { id: "actions", header: "Action", minSize: 160, cell: ({ row }) => { const isLocal = row.original.FileServerId === "LOCAL"; return (
{isLocal && onDelete && ( )}
); }, }, ];