summaryrefslogtreecommitdiff
path: root/lib/po/vendor-table/shi-vendor-po-toolbar-actions.tsx
blob: a18c02da4d0edd975d4f5262611e7bc6e0c11ca8 (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
"use client"

import * as React from "react"
import { type Table } from "@tanstack/react-table"
import { Download, RefreshCcw } from "lucide-react"
import { toast } from "sonner"

import { exportTableToExcel } from "@/lib/export"
import { Button } from "@/components/ui/button"
import { VendorPO } from "./types"

interface ShiVendorPOToolbarActionsProps {
  table: Table<VendorPO>
  selectedRows: number[]
  onAction: (poId: number, action: string) => Promise<void>
  onViewItems: (po: VendorPO) => void
}

export function ShiVendorPOToolbarActions({ 
  table, 
  selectedRows,
  onAction,
  onViewItems 
}: ShiVendorPOToolbarActionsProps) {

  const handleRefresh = async () => {
    try {
      toast.success("데이터를 새로고침했습니다.")
      // TODO: 실제 데이터 새로고침 로직 추가
      window.location.reload()
    } catch (error) {
      toast.error("데이터 새로고침 중 오류가 발생했습니다.")
    }
  }

  return (
    <div className="flex items-center gap-2">
      {/* Refresh 버튼 */}
      <Button
        variant="samsung"
        size="sm"
        className="gap-2"
        onClick={handleRefresh}
      >
        <RefreshCcw className="size-4" aria-hidden="true" />
        <span className="hidden sm:inline">Refresh</span>
      </Button>

      {/* Export 버튼 */}
      <Button
        variant="outline"
        size="sm"
        onClick={() =>
          exportTableToExcel(table, {
            filename: "vendor-po-list",
            excludeColumns: ["select", "actions"],
          })
        }
        className="gap-2"
      >
        <Download className="size-4" aria-hidden="true" />
        <span className="hidden sm:inline">Export</span>
      </Button>
    </div>
  )
}