You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
900 B
32 lines
900 B
4 years ago
|
import { useContext } from 'react';
|
||
4 years ago
|
import { Panel } from '../Panels';
|
||
|
import { HeaderText } from '../Text';
|
||
3 years ago
|
import AnvilHost from './AnvilHost';
|
||
4 years ago
|
import PeriodicFetch from '../../lib/fetchers/periodicFetch';
|
||
4 years ago
|
import { AnvilContext } from '../AnvilContext';
|
||
|
|
||
3 years ago
|
const Hosts = ({ anvil }: { anvil: AnvilListItem[] }): JSX.Element => {
|
||
4 years ago
|
const { uuid } = useContext(AnvilContext);
|
||
4 years ago
|
|
||
|
const { data } = PeriodicFetch<AnvilStatus>(
|
||
4 years ago
|
`${process.env.NEXT_PUBLIC_API_URL}/anvils/get_status?anvil_uuid=${uuid}`,
|
||
4 years ago
|
);
|
||
4 years ago
|
|
||
|
return (
|
||
|
<Panel>
|
||
3 years ago
|
<HeaderText text="Hosts" />
|
||
3 years ago
|
{anvil.findIndex((a) => a.anvil_uuid === uuid) !== -1 && data && (
|
||
3 years ago
|
<AnvilHost
|
||
|
hosts={anvil[anvil.findIndex((a) => a.anvil_uuid === uuid)].hosts.map(
|
||
|
(host, index) => {
|
||
|
return data.hosts[index];
|
||
4 years ago
|
},
|
||
|
)}
|
||
|
/>
|
||
|
)}
|
||
4 years ago
|
</Panel>
|
||
|
);
|
||
|
};
|
||
|
|
||
3 years ago
|
export default Hosts;
|