import { useContext } from 'react'; import { Box, Divider } from '@material-ui/core'; import { makeStyles } from '@material-ui/core/styles'; import { ClassNameMap } from '@material-ui/styles'; import Panel from './Panel'; import { HeaderText, BodyText } from './Text'; import PeriodicFetch from '../lib/fetchers/periodicFetch'; import { BLUE, PURPLE_OFF, DIVIDER } from '../lib/consts/DEFAULT_THEME'; import processNetworkData from './processNetwork'; import { AnvilContext } from './AnvilContext'; const useStyles = makeStyles((theme) => ({ container: { width: '100%', overflow: 'auto', height: '30vh', [theme.breakpoints.down('md')]: { height: '100%', overflow: 'hidden', }, }, root: { paddingTop: '10px', paddingBottom: '10px', }, noPaddingLeft: { paddingLeft: 0, }, divider: { background: DIVIDER, }, decorator: { width: '20px', height: '100%', borderRadius: 2, }, optimal: { backgroundColor: BLUE, }, degraded: { backgroundColor: PURPLE_OFF, }, })); const selectDecorator = ( state: string, ): keyof ClassNameMap<'optimal' | 'degraded'> => { switch (state) { case 'optimal': return 'optimal'; case 'degraded': return 'degraded'; default: return 'degraded'; } }; 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;