From 5b5ab7099b1f29323817b185518e73a5d9f6f0bf Mon Sep 17 00:00:00 2001 From: garciafdezpatricia Date: Mon, 13 May 2024 16:44:51 +0200 Subject: [PATCH] review fix Lifted the agents count and consequent search bar disabling to index.tsx --- pages/index.tsx | 6 +++++- src/components/ListAgents/ListAgentsWithVCs.tsx | 12 +++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) 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]);