import React, { useState } from 'react' import { Paper, Container, Drawer, Button, Typography, CircularProgress, Grid } from '@material-ui/core'; import ClipboardCopy from '../../components/ClipboardCopy'; import { beeDebugApi } from '../../services/bee'; import EthereumAddress from '../../components/EthereumAddress'; import { ConvertBalanceToBZZ } from '../../utils/common'; function truncStringPortion(str: string, firstCharCount=10, endCharCount=10) { var convertedStr=""; convertedStr+=str.substring(0, firstCharCount); convertedStr += ".".repeat(3); convertedStr+=str.substring(str.length-endCharCount, str.length); return convertedStr; } export default function Index(props: any) { const [open, setOpen] = useState(false); const [peerCashout, setPeerCashout] = useState({ "peer": "", "chequebook": "", "cumulativePayout": 0, "beneficiary": "", "transactionHash": "", "result": { "recipient": "", "lastPayout": 0, "bounced": false }}); const [peerCheque, setPeerCheque] = useState({ lastreceived: { beneficiary: "", payout: 0, chequebook: "" }, lastsent: { beneficiary: "", payout: 0, chequebook: "" }, peer: "" }) const [isLoadingPeerCheque, setIsLoadingPeerCheque] = useState(false) const [isLoadingPeerCashout, setIsLoadingPeerCashout] = useState(false); const handleClickOpen = (peerId: string) => { setIsLoadingPeerCashout(true) beeDebugApi.chequebook.getPeerLastCashout(peerId) .then(res => { setPeerCashout(res) }) .catch(error => { }) .finally(() => { setIsLoadingPeerCashout(false) }) setIsLoadingPeerCheque(true) beeDebugApi.chequebook.getPeerLastCheques(peerId) .then(res => { setPeerCheque(res) }) .catch(error => { }) .finally(() => { setIsLoadingPeerCheque(false) }) setOpen(true); } const handleClose = () => { setOpen(false); }; return (
Peer: { truncStringPortion(props.peerId) } { isLoadingPeerCashout || isLoadingPeerCheque ? :

Last Cheque

Last Sent

Payout: { peerCheque.lastsent?.payout ? ConvertBalanceToBZZ(peerCheque.lastsent?.payout) : '-' }

Beneficiary:

Chequebook:

Last Received

Payout: { peerCheque.lastreceived?.payout ? ConvertBalanceToBZZ(peerCheque.lastreceived?.payout) : '-'}

Beneficiary:

Chequebook:

Last Cashout

{peerCashout.cumulativePayout > 0 ?

Cumulative Payout: {peerCashout.cumulativePayout ? ConvertBalanceToBZZ(peerCashout.cumulativePayout) : '-'}

Last Payout: { peerCashout.result.lastPayout ? ConvertBalanceToBZZ(peerCashout.result.lastPayout) : '-' } {peerCashout.result.bounced ? 'Bounced' : ''}

Beneficiary:

Chequebook:

Recipient:

Transaction:

: 'None'}
}
) }