summaryrefslogtreecommitdiff
path: root/lib/gtc-contract/status/gtc-documents-table-toolbar-actions.tsx
blob: 90f2f8a8a189356f4c5f57b9de23c6bd857659ba (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
"use client"

import { type Table } from "@tanstack/react-table"
import { Download } from "lucide-react"

import { Button } from "@/components/ui/button"

import { type GtcDocumentWithRelations } from "@/db/schema/gtc"
import { CreateGtcDocumentDialog } from "./create-gtc-document-dialog"
import { exportTableToExcel } from "@/lib/export"

interface GtcDocumentsTableToolbarActionsProps {
  table: Table<GtcDocumentWithRelations>
}

export function GtcDocumentsTableToolbarActions({
  table,
}: GtcDocumentsTableToolbarActionsProps) {
  return (
    <div className="flex items-center gap-2">
      {table.getFilteredSelectedRowModel().rows.length > 0 ? (
        <Button
          variant="outline"
          size="sm"
          onClick={() =>
            exportTableToExcel(table, {
              filename: "gtc-documents",
              excludeColumns: ["select", "actions"],
            })
          }
        >
          <Download className="mr-2 size-4" aria-hidden="true" />
          Export ({table.getFilteredSelectedRowModel().rows.length})
        </Button>
      ) : null}
      <CreateGtcDocumentDialog />
    </div>
  )
}