blob: 5d2d1fc683f6e675d9cfb4727494423a6f105990 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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>
)
}
|