diff options
Diffstat (limited to 'lib/dolce/table/file-list-columns.tsx')
| -rw-r--r-- | lib/dolce/table/file-list-columns.tsx | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/lib/dolce/table/file-list-columns.tsx b/lib/dolce/table/file-list-columns.tsx new file mode 100644 index 00000000..f703d56d --- /dev/null +++ b/lib/dolce/table/file-list-columns.tsx @@ -0,0 +1,70 @@ +"use client"; + +import { ColumnDef } from "@tanstack/react-table"; +import { FileInfoItem } from "../actions"; +import { Button } from "@/components/ui/button"; +import { Download } from "lucide-react"; + +interface FileListColumnsProps { + onDownload: (file: FileInfoItem) => void; +} + +export const createFileListColumns = ({ + onDownload, +}: FileListColumnsProps): ColumnDef<FileInfoItem>[] => [ + { + accessorKey: "FileSeq", + header: "순번", + minSize: 80, + cell: ({ row }) => { + return <div className="text-center">{row.getValue("FileSeq")}</div>; + }, + }, + { + accessorKey: "FileName", + header: "파일명", + minSize: 300, + cell: ({ row }) => { + return <div className="font-medium">{row.getValue("FileName")}</div>; + }, + }, + { + accessorKey: "FileSize", + header: "파일크기", + 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: "생성일시", + minSize: 200, + cell: ({ row }) => { + return <div className="text-sm text-muted-foreground">{row.getValue("CreateDt")}</div>; + }, + }, + { + id: "actions", + header: "다운로드", + minSize: 120, + cell: ({ row }) => { + return ( + <Button + variant="outline" + size="sm" + onClick={() => onDownload(row.original)} + > + <Download className="h-4 w-4 mr-2" /> + 다운로드 + </Button> + ); + }, + }, +]; + |
