diff options
Diffstat (limited to 'lib/dolce/table/file-list-columns.tsx')
| -rw-r--r-- | lib/dolce/table/file-list-columns.tsx | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/lib/dolce/table/file-list-columns.tsx b/lib/dolce/table/file-list-columns.tsx index 36a579a3..38b1f1c9 100644 --- a/lib/dolce/table/file-list-columns.tsx +++ b/lib/dolce/table/file-list-columns.tsx @@ -3,16 +3,18 @@ import { ColumnDef } from "@tanstack/react-table"; import { FileInfoItem } from "../actions"; import { Button } from "@/components/ui/button"; -import { Download } from "lucide-react"; +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<FileInfoItem>[] => [ { @@ -20,6 +22,9 @@ export const createFileListColumns = ({ header: lng === "ko" ? "순번" : "No.", minSize: 80, cell: ({ row }) => { + if (row.original.FileServerId === "LOCAL") { + return <div className="text-center">-</div>; + } return <div className="text-center">{row.getValue("FileSeq")}</div>; }, }, @@ -55,18 +60,36 @@ export const createFileListColumns = ({ }, { id: "actions", - header: lng === "ko" ? "다운로드" : "Download", - minSize: 120, + header: "Action", + minSize: 160, cell: ({ row }) => { + const isLocal = row.original.FileServerId === "LOCAL"; return ( - <Button - variant="outline" - size="sm" - onClick={() => onDownload(row.original)} - > - <Download className="h-4 w-4 mr-2" /> - {lng === "ko" ? "다운로드" : "Download"} - </Button> + <div className="flex gap-2 items-center justify-center"> + <Button + variant="outline" + size="sm" + onClick={(e) => { + e.stopPropagation(); + onDownload(row.original); + }} + > + <Download className="h-4 w-4 mr-2" /> + {lng === "ko" ? "다운로드" : "Download"} + </Button> + {isLocal && onDelete && ( + <Button + variant="destructive" + size="sm" + onClick={(e) => { + e.stopPropagation(); + onDelete(row.original); + }} + > + <Trash2 className="h-4 w-4" /> + </Button> + )} + </div> ); }, }, |
