import { useContext } from 'react'; import { Box } from '@material-ui/core'; import { makeStyles } from '@material-ui/core/styles'; import { BodyText, HeaderText } from '../Text'; import { Panel, InnerPanel, PanelHeader } from '../Panels'; import SharedStorageNode from './SharedStorageNode'; import PeriodicFetch from '../../lib/fetchers/periodicFetch'; import { AnvilContext } from '../AnvilContext'; const useStyles = makeStyles((theme) => ({ header: { paddingTop: '0.1em', paddingRight: '0.7em', }, root: { overflow: 'auto', height: '78vh', paddingLeft: '0.3em', [theme.breakpoints.down('md')]: { height: '100%', }, }, })); const SharedStorage = ({ anvil }: { anvil: AnvilListItem[] }): JSX.Element => { const classes = useStyles(); const { uuid } = useContext(AnvilContext); const { data } = PeriodicFetch( `${process.env.NEXT_PUBLIC_API_URL}/anvils/get_shared_storage?anvil_uuid=${uuid}`, ); return ( {data?.file_systems && data.file_systems.map( (fs: AnvilSharedStorageFileSystem): JSX.Element => ( {fs?.nodes && fs.nodes.map( ( node: AnvilSharedStorageNode, index: number, ): JSX.Element => ( a.anvil_uuid === uuid)] .nodes[index], }} key={fs.nodes[index].free} /> ), )} ), )} ); }; export default SharedStorage;