import { CategoryTreeNode } from './CategoryTreeNode'
import type { RubroTreeNode, Rubro } from '../types'

export interface CategoryTreeProps {
  nodes: RubroTreeNode[]
  onEdit: (rubro: Rubro) => void
  onDelete: (rubro: Rubro) => void
  onAddChild: (parentId: number) => void
  onMove: (rubro: Rubro) => void
  canEdit: boolean
}

export function CategoryTree({
  nodes,
  onEdit,
  onDelete,
  onAddChild,
  onMove,
  canEdit,
}: CategoryTreeProps) {
  if (nodes.length === 0) {
    return (
      <div className="flex items-center justify-center py-12 text-sm text-muted-foreground">
        No hay rubros cargados
      </div>
    )
  }

  return (
    <div className="space-y-0.5">
      {nodes.map((node) => (
        <CategoryTreeNode
          key={node.id}
          node={node}
          depth={0}
          onEdit={onEdit}
          onDelete={onDelete}
          onAddChild={onAddChild}
          onMove={onMove}
          canEdit={canEdit}
        />
      ))}
    </div>
  )
}
