diff --git a/src/components/AgentButton.tsx b/src/components/AgentButton.tsx index 4d0ee89..04b09b8 100644 --- a/src/components/AgentButton.tsx +++ b/src/components/AgentButton.tsx @@ -16,10 +16,12 @@ export function AgentButton() { { name: 'Bark', boundClientIds: ['312342', '312343'], color: '#32d96c' }, { name: 'Meow', boundClientIds: [], color: '#3db9eb' }, ]) - const [boundToAgent, setBoundToAgent] = useState('Meow') + const [boundToAgent, setBoundToAgent] = useState('Bark') + const sansYou = agents.filter((agent: Agent) => agent.name !== boundToAgent) + const boundAgents = sansYou.filter((agent: Agent) => agent.boundClientIds.length > 0) + const unboundAgents = sansYou.filter((agent: Agent) => agent.boundClientIds.length === 0) const you = agents.find((agent: Agent) => agent.name === boundToAgent) - const agentsWithoutYou = agents.filter((agent: Agent) => agent.name !== boundToAgent) const handleColorChange = (name: string, color: string) => { setAgents(agents.map(agent => @@ -59,7 +61,7 @@ export function AgentButton() { onBind={() => handleBind(you.name)} />} - {agentsWithoutYou.map((agent: Agent) => ( + {boundAgents.map((agent: Agent) => ( handleBind(agent.name)} /> ))} + + {unboundAgents.map((agent: Agent) => ( + handleColorChange(agent.name, color)} + onDelete={() => handleDelete(agent.name)} + onBind={() => handleBind(agent.name)} + /> + ))} ) } -function AgentItem({ agent, onColorChange, onDelete, onBind }: { agent: Agent, onColorChange: (color: string) => void, onDelete: () => void, onBind: () => void }) { +function AgentItem({ agent, isUnbound, onColorChange, onDelete, onBind }: { agent: Agent, isUnbound?: boolean, onColorChange: (color: string) => void, onDelete: () => void, onBind: () => void }) { return
- - {agent.name} + {!isUnbound && } + {agent.name}