summaryrefslogtreecommitdiff
path: root/lib/approval-line/table/approval-line-table-toolbar-actions.tsx
blob: 6b6600febf494ebaf2f221b35a2ec9fab5d1c2a1 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
"use client"

import * as React from "react"
import { type Table } from "@tanstack/react-table"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { DataTableViewOptions } from "@/components/data-table/data-table-view-options"
import { Plus, Download, Upload } from "lucide-react"
import { type ApprovalLine } from "../service"

interface ApprovalLineTableToolbarActionsProps {
  table: Table<ApprovalLine>
  onCreateLine: () => void
}

export function ApprovalLineTableToolbarActions({
  table,
  onCreateLine,
}: ApprovalLineTableToolbarActionsProps) {
  const isFiltered = table.getState().columnFilters.length > 0

  return (
    <div className="flex items-center justify-between">
      <div className="flex flex-1 items-center space-x-2">
        <Input
          placeholder="결재선 검색..."
          value={(table.getColumn("name")?.getFilterValue() as string) ?? ""}
          onChange={(event) =>
            table.getColumn("name")?.setFilterValue(event.target.value)
          }
          className="h-8 w-[150px] lg:w-[250px]"
        />
        {isFiltered && (
          <Button
            variant="ghost"
            onClick={() => table.resetColumnFilters()}
            className="h-8 px-2 lg:px-3"
          >
            초기화
          </Button>
        )}
      </div>
      <div className="flex items-center space-x-2">
        <Button
          variant="outline"
          size="sm"
          className="ml-auto hidden h-8 lg:flex"
        >
          <Upload className="mr-2 h-4 w-4" />
          가져오기
        </Button>
        <Button
          variant="outline"
          size="sm"
          className="ml-auto hidden h-8 lg:flex"
        >
          <Download className="mr-2 h-4 w-4" />
          내보내기
        </Button>
        <DataTableViewOptions table={table} />
        <Button
          variant="outline"
          size="sm"
          className="ml-auto h-8"
          onClick={onCreateLine}
        >
          <Plus className="mr-2 h-4 w-4" />
          결재선 생성
        </Button>
      </div>
    </div>
  )
}