import { useState } from "react"; import { VOCAB } from "@paperclipai/branding"; import type { Agent } from "@paperclipai/shared"; import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover"; import { User } from "lucide-react"; import { cn } from "../lib/utils"; import { roleLabels } from "./agent-config-primitives"; import { AgentIcon } from "./AgentIconPicker"; export function ReportsToPicker({ agents, value, onChange, disabled = false, excludeAgentIds = [], disabledEmptyLabel, chooseLabel = "Reports to...", }: { agents: Agent[]; value: string | null; onChange: (id: string | null) => void; disabled?: boolean; excludeAgentIds?: string[]; disabledEmptyLabel?: string; chooseLabel?: string; }) { const label = disabledEmptyLabel ?? `Reports to: N/A (${VOCAB.ceo})`; const [open, setOpen] = useState(false); const exclude = new Set(excludeAgentIds); const rows = agents.filter( (a) => a.status !== "terminated" && !exclude.has(a.id), ); const current = value ? agents.find((a) => a.id === value) : null; const terminatedManager = current?.status === "terminated"; const unknownManager = Boolean(value && !current); return ( {terminatedManager && (
Current: {current.name} (terminated)
)} {unknownManager && (
Saved manager is missing from this company. Choose a new manager or clear.
)} {rows.map((a) => ( ))}
); }