Skip to content
Snippets Groups Projects
Commit efcadc96 authored by Johanna Szepanski's avatar Johanna Szepanski
Browse files

split findHostWithStatusById into two separate calls

parent c2b669af
No related branches found
No related tags found
2 merge requests!497CE-2790: Prepare for 4.0.0,!492CE-2887: Modify host endpoints
...@@ -6,35 +6,52 @@ import NotFoundView from "../../../components/navigation/NotFoundView/NotFoundVi ...@@ -6,35 +6,52 @@ import NotFoundView from "../../../components/navigation/NotFoundView/NotFoundVi
import { apiContext } from "../../../api/DeployApi"; import { apiContext } from "../../../api/DeployApi";
import { useAPIMethod } from "@ess-ics/ce-ui-common"; import { useAPIMethod } from "@ess-ics/ce-ui-common";
export function HostDetailsContainer({ hostId }) { export function HostDetailsContainer({ hostId, hostFqdn }) {
const [error, setError] = useState(null); const [error, setError] = useState(null);
const client = useContext(apiContext); const client = useContext(apiContext);
const params = useMemo( const statusParams = useMemo(
() => ({ () => ({
host_id: hostId host_id: hostId
}), }),
[hostId] [hostId]
); );
const hostParams = useMemo(
() => ({
fqdn: hostFqdn
}),
[hostFqdn]
);
const { value: host, error: fetchError } = useAPIMethod({ const { value: host, error: fetchError } = useAPIMethod({
fcn: client.apis.Hosts.findHostWithStatusById, fcn: client.apis.Hosts.findNetBoxHostByFqdn,
params params: hostParams
});
const { value: status, error: statusError } = useAPIMethod({
fcn: client.apis.Hosts.findHostStatus,
params: statusParams
}); });
useEffect(() => { useEffect(() => {
if (fetchError) { if (fetchError || statusError) {
onFetchEntityError(fetchError?.message, fetchError?.status, setError); const message = fetchError.message
? fetchError.message
: statusError.message;
const status = fetchError.status ? fetchError.status : statusError.status;
onFetchEntityError(message, status, setError);
} }
}, [fetchError]); }, [fetchError, statusError]);
return ( return (
<> <>
{error ? ( {error ? (
<NotFoundView /> <NotFoundView />
) : host ? ( ) : host && status ? (
<HostDetailsView <HostDetailsView
host={host} host={host}
status={status}
hostId={hostId} hostId={hostId}
/> />
) : ( ) : (
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment