Skip to content

Commit

Permalink
review fix
Browse files Browse the repository at this point in the history
Lifted the agents count and consequent search bar disabling to index.tsx
  • Loading branch information
garciafdezpatricia committed May 13, 2024
1 parent f33d507 commit 5b5ab70
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 5 additions & 1 deletion pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ export default function ManagePage() {
})
}
searchString={value}
onNotEmptyAgents={() => setDisableSearch(false)}
onAgentUpdate={(agentCount) => {
agentCount === 0
? setDisableSearch(true)
: setDisableSearch(false);
}}
/>
</div>
</main>
Expand Down
12 changes: 7 additions & 5 deletions src/components/ListAgents/ListAgentsWithVCs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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]);

Expand Down

0 comments on commit 5b5ab70

Please sign in to comment.