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.
31 lines
909 B
31 lines
909 B
import { useContext } from 'react'; |
|
import { Panel } from '../Panels'; |
|
import { HeaderText } from '../Text'; |
|
import AnvilNode from './AnvilNode'; |
|
import PeriodicFetch from '../../lib/fetchers/periodicFetch'; |
|
import { AnvilContext } from '../AnvilContext'; |
|
|
|
const Nodes = ({ anvil }: { anvil: AnvilListItem[] }): JSX.Element => { |
|
const { uuid } = useContext(AnvilContext); |
|
|
|
const { data } = PeriodicFetch<AnvilStatus>( |
|
`${process.env.NEXT_PUBLIC_API_URL}/anvils/get_status?anvil_uuid=${uuid}`, |
|
); |
|
|
|
return ( |
|
<Panel> |
|
<HeaderText text="Nodes" /> |
|
{anvil.findIndex((a) => a.anvil_uuid === uuid) !== -1 && ( |
|
<AnvilNode |
|
nodes={anvil[anvil.findIndex((a) => a.anvil_uuid === uuid)].nodes.map( |
|
(node, index) => { |
|
return { ...node, ...data?.nodes[index] }; |
|
}, |
|
)} |
|
/> |
|
)} |
|
</Panel> |
|
); |
|
}; |
|
|
|
export default Nodes;
|
|
|