"use client"

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

import { DeleteComboBoxSettingsDialog } from "./delete-combo-box-settings-dialog"
import { codeGroups } from "@/db/schema/codeGroups"

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

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


    </div>
  )
} 