diff --git a/pages/index.tsx b/pages/index.tsx index 3094b7d..24eb709 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -61,7 +61,11 @@ export default function ManagePage() { }) } searchString={value} - onNotEmptyAgents={() => setDisableSearch(false)} + onAgentUpdate={(agentCount) => { + agentCount === 0 + ? setDisableSearch(true) + : setDisableSearch(false); + }} /> diff --git a/src/components/ListAgents/ListAgentsWithVCs.tsx b/src/components/ListAgents/ListAgentsWithVCs.tsx index 06a5fec..813cac1 100644 --- a/src/components/ListAgents/ListAgentsWithVCs.tsx +++ b/src/components/ListAgents/ListAgentsWithVCs.tsx @@ -83,11 +83,11 @@ function SuspendedList({ export default function ListAgentsWithVCs({ onDetails, searchString, - onNotEmptyAgents, + onAgentUpdate, }: { onDetails: (_agent: string) => void; searchString: string; - onNotEmptyAgents?: () => void; + onAgentUpdate?: (agentCount: number) => void; }) { const { session, accessEndpoint, endpointConfiguration } = useContext(SessionContext); @@ -113,10 +113,12 @@ export default function ListAgentsWithVCs({ }, [accessEndpoint, endpointConfiguration, session, isValidAccessGrant]); useEffect(() => { - if (agents !== undefined && agents.length > 0) { - if (onNotEmptyAgents) { - onNotEmptyAgents(); + if (typeof onAgentUpdate === "function") { + let agentsCount = 0; + if (agents !== undefined) { + agentsCount = agents.length; } + onAgentUpdate(agentsCount); } }, [agents]);