diff --git a/striker-ui/components/Hosts/index.tsx b/striker-ui/components/Hosts/index.tsx index a22b2e53..9924c2d1 100644 --- a/striker-ui/components/Hosts/index.tsx +++ b/striker-ui/components/Hosts/index.tsx @@ -5,6 +5,7 @@ import AnvilHost from './AnvilHost'; import PeriodicFetch from '../../lib/fetchers/periodicFetch'; import { AnvilContext } from '../AnvilContext'; import Spinner from '../Spinner'; +import hostsSanitizer from '../../lib/sanitizers/hostsSanitizer'; const Hosts = ({ anvil }: { anvil: AnvilListItem[] }): JSX.Element => { const { uuid } = useContext(AnvilContext); @@ -13,18 +14,20 @@ const Hosts = ({ anvil }: { anvil: AnvilListItem[] }): JSX.Element => { `${process.env.NEXT_PUBLIC_API_URL}/get_status?anvil_uuid=${uuid}`, ); + const anvilIndex = anvil.findIndex((a) => a.anvil_uuid === uuid); + return ( {!isLoading ? ( <> - {anvil.findIndex((a) => a.anvil_uuid === uuid) !== -1 && data && ( + {anvilIndex !== -1 && data && ( a.anvil_uuid === uuid)].hosts - .filter((host) => host.host_uuid) - .map((host, index) => { + hosts={hostsSanitizer(anvil[anvilIndex].hosts).map( + (host, index) => { return data.hosts[index]; - })} + }, + )} /> )} diff --git a/striker-ui/lib/sanitizers/hostsSanitizer.ts b/striker-ui/lib/sanitizers/hostsSanitizer.ts new file mode 100644 index 00000000..5fbe7826 --- /dev/null +++ b/striker-ui/lib/sanitizers/hostsSanitizer.ts @@ -0,0 +1,7 @@ +const hostsSanitizer = ( + data: Array, +): Array => { + return data.filter((host) => host.host_uuid); +}; + +export default hostsSanitizer;