use vaultEvents in FundingSummary
This commit is contained in:
parent
98c1f80942
commit
de6c61ad3f
|
@ -8,7 +8,6 @@ import Card from '@material-ui/core/Card'
|
||||||
import CardContent from '@material-ui/core/CardContent'
|
import CardContent from '@material-ui/core/CardContent'
|
||||||
import Typography from '@material-ui/core/Typography'
|
import Typography from '@material-ui/core/Typography'
|
||||||
import LinearProgress from '@material-ui/core/LinearProgress'
|
import LinearProgress from '@material-ui/core/LinearProgress'
|
||||||
import { FundingContext } from '../../context'
|
|
||||||
import { getDepositWithdrawTotals, getPledgesWaitingCommit } from '../../selectors/pledging'
|
import { getDepositWithdrawTotals, getPledgesWaitingCommit } from '../../selectors/pledging'
|
||||||
import { getTokenAddress } from '../../utils/currencies'
|
import { getTokenAddress } from '../../utils/currencies'
|
||||||
|
|
||||||
|
@ -50,71 +49,67 @@ const styles = {
|
||||||
const getNet = (deposits, withdraws) => Number(deposits) - Number(withdraws)
|
const getNet = (deposits, withdraws) => Number(deposits) - Number(withdraws)
|
||||||
const getValue = (deposits, withdraws) => (getNet(deposits, withdraws) / Number(deposits)) * 100
|
const getValue = (deposits, withdraws) => (getNet(deposits, withdraws) / Number(deposits)) * 100
|
||||||
function SimpleCard(props) {
|
function SimpleCard(props) {
|
||||||
const { classes, title, transfers, pledges } = props
|
const { classes, title, transfers, pledges, vaultEvents } = props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FundingContext.Consumer>
|
<Card className={classes.card}>
|
||||||
{({ vaultEvents }) =>
|
<CardContent>
|
||||||
<Card className={classes.card}>
|
<Typography variant="h5" className={classes.cardTitle}>
|
||||||
<CardContent>
|
{title}
|
||||||
<Typography variant="h5" className={classes.cardTitle}>
|
</Typography>
|
||||||
{title}
|
{!!transfers &&
|
||||||
</Typography>
|
Object.entries(getDepositWithdrawTotals({ transfers, pledges, vaultEvents }))
|
||||||
{!!transfers &&
|
.map(token => {
|
||||||
Object.entries(getDepositWithdrawTotals({ transfers, pledges, vaultEvents }))
|
const [name, amounts] = token
|
||||||
.map(token => {
|
const { deposits, withdraws } = amounts
|
||||||
const [name, amounts] = token
|
const address = getTokenAddress(name)
|
||||||
const { deposits, withdraws } = amounts
|
const pledgesForCommit = getPledgesWaitingCommit({ pledges }).filter(p => p.token == address)
|
||||||
const address = getTokenAddress(name)
|
return (
|
||||||
const pledgesForCommit = getPledgesWaitingCommit({ pledges }).filter(p => p.token == address)
|
<Card key={name}>
|
||||||
return (
|
<Typography variant="h5" className={classes.titleText}>
|
||||||
<Card key={name}>
|
{name}
|
||||||
<Typography variant="h5" className={classes.titleText}>
|
</Typography>
|
||||||
{name}
|
<CardContent className={classes.fundingSummaries}>
|
||||||
</Typography>
|
<Typography variant="h3">
|
||||||
<CardContent className={classes.fundingSummaries}>
|
{Number(deposits) - Number(withdraws || 0)}
|
||||||
<Typography variant="h3">
|
</Typography>
|
||||||
{Number(deposits) - Number(withdraws || 0)}
|
<Typography variant="h6" key={name + 'total'} className={classes.pos} color="textSecondary">
|
||||||
</Typography>
|
Remaining In Pledges
|
||||||
<Typography variant="h6" key={name + 'total'} className={classes.pos} color="textSecondary">
|
</Typography>
|
||||||
Remaining In Pledges
|
<Typography variant="h3" >
|
||||||
</Typography>
|
{deposits}
|
||||||
<Typography variant="h3" >
|
</Typography>
|
||||||
{deposits}
|
<Typography variant="h6" key={name + 'withdraw'} className={classes.pos} color="textSecondary">
|
||||||
</Typography>
|
Funded
|
||||||
<Typography variant="h6" key={name + 'withdraw'} className={classes.pos} color="textSecondary">
|
</Typography>
|
||||||
Funded
|
<Typography variant="h3">
|
||||||
</Typography>
|
{withdraws || 0}
|
||||||
<Typography variant="h3">
|
</Typography>
|
||||||
{withdraws || 0}
|
<Typography variant="h6" key={name + 'deposit'} className={classes.pos} color="textSecondary">
|
||||||
</Typography>
|
Withdrawn
|
||||||
<Typography variant="h6" key={name + 'deposit'} className={classes.pos} color="textSecondary">
|
</Typography>
|
||||||
Withdrawn
|
<Typography variant="h3">
|
||||||
</Typography>
|
{pledgesForCommit.length}
|
||||||
<Typography variant="h3">
|
</Typography>
|
||||||
{pledgesForCommit.length}
|
<Typography variant="h6" key={name + 'veto/approve'} className={classes.pos} color="textSecondary">
|
||||||
</Typography>
|
Pledges that can be vetoed / approved
|
||||||
<Typography variant="h6" key={name + 'veto/approve'} className={classes.pos} color="textSecondary">
|
</Typography>
|
||||||
Pledges that can be vetoed / approved
|
</CardContent>
|
||||||
</Typography>
|
<LinearProgress
|
||||||
</CardContent>
|
classes={{
|
||||||
<LinearProgress
|
colorPrimary: classes.linearColorPrimary,
|
||||||
classes={{
|
barColorPrimary: classes.linearBarColorPrimary,
|
||||||
colorPrimary: classes.linearColorPrimary,
|
}}
|
||||||
barColorPrimary: classes.linearBarColorPrimary,
|
color="primary"
|
||||||
}}
|
variant="buffer"
|
||||||
color="primary"
|
value={getValue(deposits, withdraws)}
|
||||||
variant="buffer"
|
valueBuffer={100}
|
||||||
value={getValue(deposits, withdraws)}
|
/>
|
||||||
valueBuffer={100}
|
</Card>
|
||||||
/>
|
)
|
||||||
</Card>
|
})}
|
||||||
)
|
</CardContent>
|
||||||
})}
|
</Card>
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
}
|
|
||||||
</FundingContext.Consumer>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +117,8 @@ SimpleCard.propTypes = {
|
||||||
classes: PropTypes.object.isRequired,
|
classes: PropTypes.object.isRequired,
|
||||||
title: PropTypes.string,
|
title: PropTypes.string,
|
||||||
pledges: PropTypes.array.isRequired,
|
pledges: PropTypes.array.isRequired,
|
||||||
transfers: PropTypes.array.isRequired
|
transfers: PropTypes.array.isRequired,
|
||||||
|
vaultEvents: PropTypes.array.isRequired
|
||||||
}
|
}
|
||||||
|
|
||||||
const styledCard = withStyles(styles)(SimpleCard)
|
const styledCard = withStyles(styles)(SimpleCard)
|
||||||
|
@ -130,5 +126,6 @@ export default withDatabase(withObservables([], ({ database }) => ({
|
||||||
transfers: database.collections.get('lp_events').query(
|
transfers: database.collections.get('lp_events').query(
|
||||||
Q.where('event', 'Transfer')
|
Q.where('event', 'Transfer')
|
||||||
).observe(),
|
).observe(),
|
||||||
|
vaultEvents : database.collections.get('vault_events').query().observe()
|
||||||
}))(styledCard))
|
}))(styledCard))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue