import React, { useState } from 'react'; import { useSelector } from 'react-redux'; import { Typography, Container, Paper, AppBar, Toolbar, IconButton, Table, TableHead, TableRow, TableCell, TableBody, } from '@mui/material'; import makeStyles from '@mui/styles/makeStyles'; import ArrowBackIcon from '@mui/icons-material/ArrowBack'; import { useNavigate, useParams } from 'react-router-dom'; import { useEffectAsync } from '../reactHelper'; const useStyles = makeStyles((theme) => ({ root: { height: '100%', display: 'flex', flexDirection: 'column', }, content: { overflow: 'auto', paddingTop: theme.spacing(2), paddingBottom: theme.spacing(2), display: 'flex', flexDirection: 'column', gap: theme.spacing(2), }, })); const NetworkPage = () => { const classes = useStyles(); const navigate = useNavigate(); const { positionId } = useParams(); const [item, setItem] = useState({}); useEffectAsync(async () => { if (positionId) { const response = await fetch(`/api/positions?id=${positionId}`); if (response.ok) { const positions = await response.json(); if (positions.length > 0) { setItem(positions[0]); } } else { throw Error(await response.text()); } } }, [positionId]); const deviceName = useSelector((state) => { if (item) { const device = state.devices.items[item.deviceId]; if (device) { return device.name; } } return null; }); return (