import {useEffect, useState} from "react"; import Card from '@material-ui/core/Card'; import CardContent from '@material-ui/core/CardContent'; import Typography from '@material-ui/core/Typography'; import {makeStyles} from '@material-ui/core/styles'; function aggregateAssetsBy(assets, field) { let total = 0.0 for (let key in assets) { if (assets[key]) { let a = assets[key] let value = a[field] total += value } } return total } const useStyles = makeStyles((theme) => ({ root: { margin: theme.spacing(1), }, title: { fontSize: 14, }, pos: { marginTop: 12, }, })); export default function TotalAssetSummary({ assets }) { const classes = useStyles(); return Total Account Balance {Math.round(aggregateAssetsBy(assets, "inBTC") * 1e8) / 1e8} BTC Estimated Value {Math.round(aggregateAssetsBy(assets, "inUSD") * 100) / 100} USD }