import { SubIndustry } from "@/types";
import IconButton from "./IconButton";
import InlineEdit from "./InlineEdit";
import { Pencil, Trash2 } from "lucide-react";

export default function SubIndustryRow({ sub, isEditing, onEdit, onSave, onCancel, onDelete }: {
  sub: SubIndustry; isEditing: boolean
  onEdit: () => void; onSave: (v: string) => void; onCancel: () => void; onDelete: () => void
}) {
  return (
    <div className="flex items-center gap-2 px-10 py-2.5 group/sub hover:bg-white">
      <span className="w-1.5 h-1.5 rounded-full bg-gray-300 flex-shrink-0" />
      {isEditing
        ? <InlineEdit value={sub.name} onSave={onSave} onCancel={onCancel} />
        : <span className="flex-1 text-sm text-gray-700">{sub.name}</span>
      }
      {!isEditing && (
        <div className="flex items-center gap-1 opacity-0 group-hover/sub:opacity-100 transition-opacity">
          <IconButton onClick={onEdit} hoverClass="hover:bg-gray-100 hover:text-blue-600"><Pencil className="w-3 h-3" /></IconButton>
          <IconButton onClick={onDelete} hoverClass="hover:bg-red-50 hover:text-red-600"><Trash2 className="w-3 h-3" /></IconButton>
        </div>
      )}
    </div>
  )
}
