import React, { ReactElement, useState } from 'react' import { makeStyles } from '@material-ui/core/styles' import { Table, TableBody, TableCell, TableContainer, TableRow, TableHead, Button, Paper, Tooltip, CircularProgress, } from '@material-ui/core' import { Autorenew } from '@material-ui/icons' import { beeDebugApi } from '../../services/bee' import type { Peer } from '@ethersphere/bee-js' const useStyles = makeStyles({ table: { minWidth: 650, }, }) interface Props { peers: Peer[] | null } function PeerTable(props: Props): ReactElement { const classes = useStyles() const [peerLatency, setPeerLatency] = useState([{ peerId: '', rtt: '', loading: false }]) const PingPeer = (peerId: string) => { setPeerLatency([...peerLatency, { peerId: peerId, rtt: '', loading: true }]) beeDebugApi.connectivity .ping(peerId) .then(res => { setPeerLatency([...peerLatency, { peerId: peerId, rtt: res.rtt, loading: false }]) }) .catch(() => { setPeerLatency([...peerLatency, { peerId: peerId, rtt: 'error', loading: false }]) }) } return (
Index Peer Id Actions {props.peers?.map((peer: Peer, idx: number) => ( {idx + 1} {peer.address} ))}
) } export default PeerTable