diff options
Diffstat (limited to 'lib/cover/table/projects-table-toolbar-actions.tsx')
| -rw-r--r-- | lib/cover/table/projects-table-toolbar-actions.tsx | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/cover/table/projects-table-toolbar-actions.tsx b/lib/cover/table/projects-table-toolbar-actions.tsx new file mode 100644 index 00000000..5d2d1fc6 --- /dev/null +++ b/lib/cover/table/projects-table-toolbar-actions.tsx @@ -0,0 +1,50 @@ +"use client" + +import * as React from "react" +import { type Table } from "@tanstack/react-table" +import { Download, RefreshCcw, FileText } from "lucide-react" +import { toast } from "sonner" + +import { exportTableToExcel } from "@/lib/export" +import { Button } from "@/components/ui/button" +import { Project } from "@/db/schema" +import { CoverTemplateDialog } from "./cover-template-dialog" + +interface ItemsTableToolbarActionsProps { + table: Table<Project> +} + +export function ProjectTableToolbarActions({ table }: ItemsTableToolbarActionsProps) { + const [templateDialogOpen, setTemplateDialogOpen] = React.useState(false) + const [selectedProject, setSelectedProject] = React.useState<Project | null>(null) + + const handleTemplateClick = () => { + const selectedRows = table.getFilteredSelectedRowModel().rows + if (selectedRows.length !== 1) { + toast.error("프로젝트를 하나만 선택해주세요") + return + } + setSelectedProject(selectedRows[0].original) + setTemplateDialogOpen(true) + } + + return ( + <div className="flex items-center gap-2"> + <Button + variant="outline" + size="sm" + onClick={handleTemplateClick} + disabled={table.getFilteredSelectedRowModel().rows.length !== 1} + > + <FileText className="mr-2 h-4 w-4" /> + 커버 페이지 템플릿 + </Button> + + <CoverTemplateDialog + open={templateDialogOpen} + onOpenChange={setTemplateDialogOpen} + project={selectedProject} + /> + </div> + ) +}
\ No newline at end of file |
