bc01d60728
* style: add eslint configuration as per bee-js * chore: add `plugin:react/reocommended` in `.eslintrc` Co-authored-by: nugaon <50576770+nugaon@users.noreply.github.com> * chore: add `consistent` to `array-bracket-newline` as per review * style: after automatic fixes with `npm run lint` * style: fixed all linter errors * refactor: fixed all linter warnings * chore: added missing new line at end of `.prettierrc` file Co-authored-by: nugaon <50576770+nugaon@users.noreply.github.com>
70 lines
1.9 KiB
TypeScript
70 lines
1.9 KiB
TypeScript
import { 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 { ConvertBalanceToBZZ } from '../../utils/common'
|
|
|
|
import type { AllSettlements, Settlements } from '@ethersphere/bee-js'
|
|
|
|
const useStyles = makeStyles({
|
|
table: {
|
|
minWidth: 650,
|
|
},
|
|
})
|
|
|
|
interface Props {
|
|
nodeSettlements: AllSettlements | null
|
|
loading?: boolean
|
|
}
|
|
|
|
function SettlementsTable(props: Props): ReactElement {
|
|
const classes = useStyles()
|
|
|
|
return (
|
|
<div>
|
|
{props.loading ? (
|
|
<Container style={{ textAlign: 'center', padding: '50px' }}>
|
|
<CircularProgress />
|
|
</Container>
|
|
) : (
|
|
<TableContainer component={Paper}>
|
|
<Table className={classes.table} size="small" aria-label="simple table">
|
|
<TableHead>
|
|
<TableRow>
|
|
<TableCell>Peer</TableCell>
|
|
<TableCell>Received (BZZ)</TableCell>
|
|
<TableCell>Sent (BZZ)</TableCell>
|
|
</TableRow>
|
|
</TableHead>
|
|
<TableBody>
|
|
{props.nodeSettlements?.settlements.map((item: Settlements) => (
|
|
<TableRow key={item.peer}>
|
|
<TableCell>{item.peer}</TableCell>
|
|
<TableCell style={{ fontFamily: 'monospace, monospace' }}>
|
|
{item.received > 0 ? ConvertBalanceToBZZ(item.received).toFixed(7).toLocaleString() : item.received}
|
|
</TableCell>
|
|
<TableCell style={{ fontFamily: 'monospace, monospace' }}>
|
|
{item.sent > 0 ? ConvertBalanceToBZZ(item.sent).toFixed(7).toLocaleString() : item.sent}
|
|
</TableCell>
|
|
</TableRow>
|
|
))}
|
|
</TableBody>
|
|
</Table>
|
|
</TableContainer>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default SettlementsTable
|