From aa1644fd8bc7eb6d843d512ae075754a82762691 Mon Sep 17 00:00:00 2001 From: garciafdezpatricia Date: Thu, 9 May 2024 18:11:19 +0200 Subject: [PATCH] less impact change --- pages/index.tsx | 4 ++-- src/components/ListAgents/ListAgents.tsx | 5 ----- src/components/ListAgents/ListAgentsWithVCs.tsx | 16 ++++++++++------ 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/pages/index.tsx b/pages/index.tsx index bec4335..3094b7d 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -29,7 +29,7 @@ import AuthenticatedRoute from "../src/authentication/context/AuthenticatedRoute export default function ManagePage() { const [value, setValue] = useState(""); - const [disableSearch, setDisableSearch] = useState(false); + const [disableSearch, setDisableSearch] = useState(true); const { push } = useRouter(); return ( @@ -61,7 +61,7 @@ export default function ManagePage() { }) } searchString={value} - onEmptyAgents={() => setDisableSearch(true)} + onNotEmptyAgents={() => setDisableSearch(false)} /> diff --git a/src/components/ListAgents/ListAgents.tsx b/src/components/ListAgents/ListAgents.tsx index 62eaf28..85a0d65 100644 --- a/src/components/ListAgents/ListAgents.tsx +++ b/src/components/ListAgents/ListAgents.tsx @@ -126,17 +126,12 @@ export default function ListAgents({ agents, onDetails, searchString, - onEmptyAgents, }: { agents: string[]; searchString?: string; onDetails: (_agent: string) => void; - onEmptyAgents?: () => void; }) { if (agents.length === 0) { - if (onEmptyAgents) { - onEmptyAgents(); - } return ; } return ( diff --git a/src/components/ListAgents/ListAgentsWithVCs.tsx b/src/components/ListAgents/ListAgentsWithVCs.tsx index f562233..06a5fec 100644 --- a/src/components/ListAgents/ListAgentsWithVCs.tsx +++ b/src/components/ListAgents/ListAgentsWithVCs.tsx @@ -63,12 +63,10 @@ function SuspendedList({ onDetails, searchString, agents, - onEmptyAgents, }: { onDetails: (_agent: string) => void; searchString: string; agents?: string[]; - onEmptyAgents?: () => void; }) { if (agents === undefined) { return ; @@ -78,7 +76,6 @@ function SuspendedList({ agents={agents} onDetails={onDetails} searchString={searchString} - onEmptyAgents={onEmptyAgents} /> ); } @@ -86,11 +83,11 @@ function SuspendedList({ export default function ListAgentsWithVCs({ onDetails, searchString, - onEmptyAgents, + onNotEmptyAgents, }: { onDetails: (_agent: string) => void; searchString: string; - onEmptyAgents?: () => void; + onNotEmptyAgents?: () => void; }) { const { session, accessEndpoint, endpointConfiguration } = useContext(SessionContext); @@ -115,12 +112,19 @@ export default function ListAgentsWithVCs({ } }, [accessEndpoint, endpointConfiguration, session, isValidAccessGrant]); + useEffect(() => { + if (agents !== undefined && agents.length > 0) { + if (onNotEmptyAgents) { + onNotEmptyAgents(); + } + } + }, [agents]); + return ( ); }