diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-10-15 12:52:11 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-10-15 12:52:11 +0000 |
| commit | b54f6f03150dd78d86db62201b6386bf14b72394 (patch) | |
| tree | b3092bb34805fdc65eee5282e86a9fb90ba20d6e /lib/cover/table/projects-table-columns.tsx | |
| parent | c1bd1a2f499ee2f0742170021b37dab410983ab7 (diff) | |
(대표님) 커버, 데이터룸, 파일매니저, 담당자할당 등
Diffstat (limited to 'lib/cover/table/projects-table-columns.tsx')
| -rw-r--r-- | lib/cover/table/projects-table-columns.tsx | 187 |
1 files changed, 187 insertions, 0 deletions
diff --git a/lib/cover/table/projects-table-columns.tsx b/lib/cover/table/projects-table-columns.tsx new file mode 100644 index 00000000..9ed36436 --- /dev/null +++ b/lib/cover/table/projects-table-columns.tsx @@ -0,0 +1,187 @@ +"use client" + +import * as React from "react" +import { type DataTableRowAction } from "@/types/table" +import { type ColumnDef } from "@tanstack/react-table" +import { Download, Eye, FileText, FilePlus } from "lucide-react" +import { Checkbox } from "@/components/ui/checkbox"; + +import { formatDate } from "@/lib/utils" +import { Button } from "@/components/ui/button" +import { quickDownload } from "@/lib/file-download" + +import { DataTableColumnHeaderSimple } from "@/components/data-table/data-table-column-simple-header" +import { Project } from "@/db/schema" + +interface GetColumnsProps { + setRowAction: React.Dispatch<React.SetStateAction<DataTableRowAction<Project> | null>> + onDetailClick: (project: Project) => void + onTemplateManage: (project: Project) => void +} + +export function getColumns({ setRowAction, onDetailClick, onTemplateManage }: GetColumnsProps): ColumnDef<Project>[] { + return [ + // Checkbox + { + id: "select", + header: ({ table }) => ( + <Checkbox + checked={table.getIsAllPageRowsSelected() || (table.getIsSomePageRowsSelected() && "indeterminate")} + onCheckedChange={(v) => table.toggleAllPageRowsSelected(!!v)} + aria-label="select all" + className="translate-y-0.5" + /> + ), + cell: ({ row }) => ( + <Checkbox + checked={row.getIsSelected()} + onCheckedChange={(v) => row.toggleSelected(!!v)} + aria-label="select row" + className="translate-y-0.5" + /> + ), + size: 40, + enableSorting: false, + enableHiding: false, + }, + { + accessorKey: "code", + enableResizing: true, + header: ({ column }) => ( + <DataTableColumnHeaderSimple column={column} title="프로젝트 코드" /> + ), + meta: { + excelHeader: "Project Code", + }, + }, + { + accessorKey: "name", + enableResizing: true, + header: ({ column }) => ( + <DataTableColumnHeaderSimple column={column} title="프로젝트명" /> + ), + meta: { + excelHeader: "Project Name", + }, + }, + { + id: "coverTemplate", + enableResizing: true, + header: "커버 템플릿", + cell: ({ row }) => { + const project = row.original + const hasTemplate = !!project.coverTemplatePath + + return ( + <div className="flex items-center gap-2"> + {hasTemplate ? ( + <> + <Button + variant="ghost" + size="sm" + onClick={() => quickDownload(project.coverTemplatePath!, `${project.code}_template.docx`)} + title="템플릿 다운로드" + > + <FileText className="h-4 w-4 text-blue-600" /> + </Button> + <Button + variant="ghost" + size="sm" + onClick={() => onTemplateManage(project)} + title="템플릿 관리" + > + <Eye className="h-4 w-4" /> + </Button> + </> + ) : ( + <Button + variant="outline" + size="sm" + onClick={() => onTemplateManage(project)} + > + <FilePlus className="h-4 w-4 mr-1" /> + 생성 + </Button> + )} + </div> + ) + }, + }, + { + id: "generatedCover", + enableResizing: true, + header: "생성된 커버", + cell: ({ row }) => { + const project = row.original + const hasGenerated = !!project.generatedCoverPath + const generatedAt = project.generatedCover?.generatedAt + + return ( + <div className="flex flex-col gap-1"> + {hasGenerated ? ( + <> + <Button + variant="ghost" + size="sm" + onClick={() => quickDownload( + project.generatedCoverPath!, + project.generatedCover?.fileName || `${project.code}_cover.docx` + )} + className="justify-start" + > + <Download className="h-4 w-4 mr-2 text-green-600" /> + <span className="text-xs">다운로드</span> + </Button> + {generatedAt && ( + <span className="text-xs text-muted-foreground pl-2"> + {formatDate(new Date(generatedAt), "KR")} + </span> + )} + </> + ) : ( + <span className="text-xs text-muted-foreground px-2">-</span> + )} + </div> + ) + }, + }, + { + accessorKey: "OWN_NM", + enableResizing: true, + header: ({ column }) => ( + <DataTableColumnHeaderSimple column={column} title="선주명" /> + ), + meta: { + excelHeader: "Owner Name", + }, + }, + { + accessorKey: "createdAt", + enableResizing: true, + header: ({ column }) => ( + <DataTableColumnHeaderSimple column={column} title="생성일" /> + ), + meta: { + excelHeader: "Created At", + }, + cell: ({ cell }) => { + const dateVal = cell.getValue() as Date + return formatDate(dateVal, "KR") + }, + }, + { + accessorKey: "updatedAt", + enableResizing: true, + header: ({ column }) => ( + <DataTableColumnHeaderSimple column={column} title="수정일" /> + ), + meta: { + excelHeader: "Updated At", + }, + cell: ({ cell }) => { + const dateVal = cell.getValue() as Date + return formatDate(dateVal, "KR") + }, + }, + ] +}
\ No newline at end of file |
