// initial-rfq-detail-toolbar-actions.tsx
"use client"

import * as React from "react"
import { type Table } from "@tanstack/react-table"
import { Button } from "@/components/ui/button"
import { 
  Download, 
  Mail, 
  RefreshCw, 
  Settings,
  Trash2,
  FileText
} from "lucide-react"

interface InitialRfqDetailTableToolbarActionsProps {
  table: Table<any>
  rfqId?: number
}

export function InitialRfqDetailTableToolbarActions({
  table,
  rfqId
}: InitialRfqDetailTableToolbarActionsProps) {
  
  // 선택된 행들 가져오기
  const selectedRows = table.getFilteredSelectedRowModel().rows
  const selectedDetails = selectedRows.map((row) => row.original)
  const selectedCount = selectedRows.length

  const handleBulkEmail = () => {
    console.log("Bulk email to selected vendors:", selectedDetails)
    // 벌크 이메일 로직 구현
  }

  const handleBulkDelete = () => {
    console.log("Bulk delete selected items:", selectedDetails)
    // 벌크 삭제 로직 구현
    table.toggleAllRowsSelected(false)
  }

  const handleExport = () => {
    console.log("Export data:", selectedCount > 0 ? selectedDetails : "all data")
    // 데이터 엑스포트 로직 구현
  }

  const handleRefresh = () => {
    window.location.reload()
  }

  return (
    <div className="flex items-center gap-2">
      {/** 선택된 항목이 있을 때만 표시되는 액션들 */}
      {selectedCount > 0 && (
        <>
          <Button
            variant="outline"
            size="sm"
            onClick={handleBulkEmail}
            className="h-8"
          >
            <Mail className="mr-2 h-4 w-4" />
            이메일 발송 ({selectedCount})
          </Button>
          
          <Button
            variant="outline"
            size="sm"
            onClick={handleBulkDelete}
            className="h-8 text-red-600 hover:text-red-700"
          >
            <Trash2 className="mr-2 h-4 w-4" />
            삭제 ({selectedCount})
          </Button>
        </>
      )}

      {/** 항상 표시되는 액션들 */}
      <Button
        variant="outline"
        size="sm"
        onClick={handleExport}
        className="h-8"
      >
        <Download className="mr-2 h-4 w-4" />
        엑스포트
      </Button>

      <Button
        variant="outline"
        size="sm"
        onClick={handleRefresh}
        className="h-8"
      >
        <RefreshCw className="mr-2 h-4 w-4" />
        새로고침
      </Button>

      <Button
        variant="outline"
        size="sm"
        className="h-8"
      >
        <Settings className="mr-2 h-4 w-4" />
        설정
      </Button>
    </div>
  )
}
