"use client"

import * as React from "react"
import { type Table } from "@tanstack/react-table"

import { DeleteDocumentClassDialog } from "./delete-document-class-dialog"
import { DocumentClassAddDialog } from "./document-class-add-dialog"
import { documentClasses } from "@/db/schema"

interface DocumentClassTableToolbarActionsProps {
  table: Table<typeof documentClasses.$inferSelect>
  onSuccess?: () => void
}

export function DocumentClassTableToolbarActions({ table, onSuccess }: DocumentClassTableToolbarActionsProps) {
  return (
    <div className="flex items-center gap-2">
      {/** 1) 선택된 로우가 있으면 삭제 다이얼로그 */}
      {table.getFilteredSelectedRowModel().rows.length > 0 ? (
        <DeleteDocumentClassDialog
          documentClasses={table
            .getFilteredSelectedRowModel()
            .rows.map((row) => row.original)}
          onSuccess={() => {
            table.toggleAllRowsSelected(false)
            onSuccess?.()
          }}
        />
      ) : null}

      <DocumentClassAddDialog onSuccess={onSuccess} />
    </div>
  )
} 