diff --git a/src/components/projects/ProjectPledges.jsx b/src/components/projects/ProjectPledges.jsx index 50d5545..f306f20 100644 --- a/src/components/projects/ProjectPledges.jsx +++ b/src/components/projects/ProjectPledges.jsx @@ -17,8 +17,6 @@ import Tab from '@material-ui/core/Tab' import { toEther } from '../../utils/conversions' import { getTokenLabel } from '../../utils/currencies' -// create form with cards showing multiple pledges, allow each to be selected and use mWithdraw to submit a withdrawal for them all - const { mWithdraw, withdraw } = LiquidPledging.methods const { confirmPayment } = LPVault.methods const { utils } = web3 @@ -40,6 +38,11 @@ const pledgeTypes = { 1: PAYING, 2: PAID } +const buttonText = { + 0: 'Submit for withdraw', + 1: 'Confirm withdraw', + 2: 'Already paid' +} const getCommitTime = async (pledge, setState) => { const { commitTime } = pledge @@ -94,7 +97,7 @@ const styles = theme => ({ } }) -function SimplePledge({ classes, pledge, values, handleChange }) { +function SimplePledge({ classes, pledge, values, handleChange, pledgeType }) { const [commitTime, setCommitTime] = useState(0); const pledgeId = `pledge.${pledge.id}` const keys = Object.keys(values) @@ -104,6 +107,8 @@ function SimplePledge({ classes, pledge, values, handleChange }) { getCommitTime(pledge, setCommitTime) }, [pledge]) + const notPaid = pledgeTypes[pledgeType] !== PAID + const notPaying = pledgeTypes[pledgeType] !== PAYING return ( @@ -116,11 +121,11 @@ function SimplePledge({ classes, pledge, values, handleChange }) { Pledge Status: {pledgeTypes[pledge.pledgeState]} - + {notPaid && Commit Time: {commitTime} - + } - + {notPaid && } - label="withdraw" + label={notPaying ? 'Withdraw' : 'Confirm'} /> - + } ); } SimplePledge.propTypes = { classes: PropTypes.object.isRequired, - pledge: PropTypes.object.isRequired + pledge: PropTypes.object.isRequired, + values: PropTypes.object.isRequired, + handleChange: PropTypes.func.isRequired, + pledgeType: PropTypes.number.isRequired }; const PledgeInfo = withStyles(styles)(SimplePledge); @@ -178,7 +186,6 @@ const SubmissionSection = ({ classes, openSnackBar, pledges, pledgeType }) => { .map(pledge => pledges.find(p => p.id === pledge)) const sendFn = getSendFn(pledgeType, filteredPledges) const args = getArgs(pledgeType, filteredPledges) - console.log({args, sendFn}) const toSend = sendFn(...args) const estimatedGas = await toSend.estimateGas() console.log({estimatedGas}) @@ -208,9 +215,8 @@ const SubmissionSection = ({ classes, openSnackBar, pledges, pledgeType }) => { }) => { return (
- {pledges.map(pledge => )} - + {pledges.map(pledge => )} + {pledgeTypes[pledgeType] !== PAID && } ) } @@ -250,12 +256,12 @@ function CenteredTabs({ pledged, paying, paid, pledgeType, setPledgeType }) { ); } -function ProjectPledges({classes, match, delegates: _delegates, projectAddedEvents, delegateAddedEvents: _delegateAddedEvents, pledges, authorizedPayments}) { +function ProjectPledges({classes, match, projectAddedEvents, pledges, authorizedPayments}) { const [pledgeType, setPledgeType] = useState(0) const projectId = match.params.id const { manifest, delegateProfiles, openSnackBar } = useProjectData(projectId, projectAddedEvents) const delegatePledges = useProfileData(delegateProfiles) - const enrichedPledges = usePledgesAuthorizations(pledges, authorizedPayments) + const enrichedPledges = usePledgesAuthorizations(pledges, authorizedPayments).filter(p => Number(p.amount) > 0) const pledged = enrichedPledges.filter(p => p.pledgeState === 0) const paying = enrichedPledges.filter(p => p.pledgeState === 1) const paid = enrichedPledges.filter(p => p.pledgeState === 2) @@ -264,7 +270,6 @@ function ProjectPledges({classes, match, delegates: _delegates, projectAddedEven 1: paying, 2: paid } - console.log('pledges', {pledges, authorizedPayments, enrichedPledges}) return (
@@ -296,9 +301,6 @@ export default withDatabase(withObservables([], ({ database, match }) => ({ projectAddedEvents: database.collections.get('lp_events').query( Q.where('event', 'ProjectAdded') ).observe(), - delegateAddedEvents: database.collections.get('lp_events').query( - Q.where('event', 'DelegateAdded') - ).observe(), pledges: database.collections.get('pledges').query( Q.or( Q.where('intended_project', match.params.id),