import type { ReactElement } from 'react' import { makeStyles } from '@material-ui/core/styles' import { Table, TableBody, TableCell, TableContainer, TableRow, TableHead, Paper, Container, CircularProgress, } from '@material-ui/core' import { fromBZZbaseUnit } from '../../utils' import EthereumAddress from '../../components/EthereumAddress' import ClipboardCopy from '../../components/ClipboardCopy' import PeerDetailDrawer from './PeerDetailDrawer' const useStyles = makeStyles({ table: { minWidth: 650, }, }) interface ChequeEvent { beneficiary: string chequebook: string payout: number } interface PeerCheque { lastreceived?: ChequeEvent lastsent?: ChequeEvent peer: string } interface PeerCheques { lastcheques: Array } interface Props { peerCheques: PeerCheques | null loading?: boolean } function ChequebookTable(props: Props): ReactElement { const classes = useStyles() return (
{props.loading ? ( ) : (
Peer Last Received Last Sent {props.peerCheques?.lastcheques.map((peerCheque: PeerCheque) => (

{peerCheque.lastreceived?.payout ? `${fromBZZbaseUnit(peerCheque.lastreceived?.payout).toFixed(7).toLocaleString()} from` : '-'} {peerCheque.lastreceived ? ( ) : null}

{peerCheque.lastsent?.payout ? `${fromBZZbaseUnit(peerCheque.lastsent?.payout).toFixed(7).toLocaleString()} to` : '-'} {peerCheque.lastsent ? ( ) : null}

))}
)}
) } export default ChequebookTable