fix(striker-ui): remove undefined hosts after host sanitize

The back-end is currently ignoring requests for status on the DR
host(s) because we don't need to show DR status in the UI (for now).
The front-end gets undefined when trying to match a DR host array index
to the AnvilStatusHost[].

This change filters out the undefined item(s) to prevent crashing.
main
Tsu-ba-me 3 years ago
parent 071ba8f099
commit 7d4e791565
  1. 16
      striker-ui/components/Hosts/index.tsx

@ -23,11 +23,17 @@ const Hosts = ({ anvil }: { anvil: AnvilListItem[] }): JSX.Element => {
<>
{anvilIndex !== -1 && data && (
<AnvilHost
hosts={hostsSanitizer(anvil[anvilIndex].hosts).map(
(host, index) => {
return data.hosts[index];
},
)}
hosts={hostsSanitizer(anvil[anvilIndex].hosts).reduce<
Array<AnvilStatusHost>
>((reducedHosts, host, index) => {
const hostStatus = data.hosts[index];
if (hostStatus) {
reducedHosts.push(hostStatus);
}
return reducedHosts;
}, [])}
/>
)}
</>

Loading…
Cancel
Save