import { useContext } from 'react'; import { Box, Divider } from '@material-ui/core'; import { makeStyles } from '@material-ui/core/styles'; import { Panel } from '../Panels'; import { HeaderText, BodyText } from '../Text'; import PeriodicFetch from '../../lib/fetchers/periodicFetch'; import { DIVIDER } from '../../lib/consts/DEFAULT_THEME'; import processNetworkData from './processNetwork'; import { AnvilContext } from '../AnvilContext'; import Decorator, { Colours } from '../Decorator'; const useStyles = makeStyles((theme) => ({ container: { width: '100%', overflow: 'auto', height: '32vh', [theme.breakpoints.down('md')]: { height: '100%', overflow: 'hidden', }, }, root: { paddingTop: '.7em', paddingBottom: '.7em', }, noPaddingLeft: { paddingLeft: 0, }, divider: { background: DIVIDER, }, })); const selectDecorator = (state: string): Colours => { switch (state) { case 'optimal': return 'ok'; case 'degraded': return 'warning'; default: return 'warning'; } }; const Network = (): JSX.Element => { const { uuid } = useContext(AnvilContext); const classes = useStyles(); const { data } = PeriodicFetch( `${process.env.NEXT_PUBLIC_API_URL}/anvils/get_network?anvil_uuid=${uuid}`, ); const processed = processNetworkData(data); return ( {data && processed.bonds.map((bond: ProcessedBond) => { return ( <> {bond.nodes.map( (node): JSX.Element => ( ), )} ); })} ); }; export default Network;