diff --git a/app/components/PledgesTable.jsx b/app/components/PledgesTable.jsx index d44162e..c65e40a 100644 --- a/app/components/PledgesTable.jsx +++ b/app/components/PledgesTable.jsx @@ -7,12 +7,18 @@ import WithdrawCard from './table/WithdrawCard' const convertToHours = seconds => seconds / 60 / 60 const projectText = project => project === '0' ? 'N/A' : project +const pledgeStateMap = { + 0: 'Pledged', + 1: 'Paying', + 2: 'Paid' +} const formatField = field => ({ ...field, commitTime: convertToHours(field.commitTime), amount: toEther(field.amount), token: getTokenLabel(field.token), - intendedProject: projectText(field.intendedProject) + intendedProject: projectText(field.intendedProject), + pledgeState: pledgeStateMap[field.pledgeState] }) class PledgesTable extends PureComponent { state = { @@ -48,6 +54,7 @@ class PledgesTable extends PureComponent { { title: 'Commit Time', field: 'commitTime', type: 'numeric' }, { title: 'Number of Delegates', field: 'nDelegates', type: 'numeric' }, { title: 'Intended Project', field: 'intendedProject' }, + { title: 'Pledge State', field: 'pledgeState' }, ]} data={data.map(formatField)} title="Pledges" @@ -69,7 +76,7 @@ class PledgesTable extends PureComponent { } ]} /> - {rowData && } + {rowData && } ) } diff --git a/app/components/table/WithdrawCard.jsx b/app/components/table/WithdrawCard.jsx index 6d2c3b9..2c7d714 100644 --- a/app/components/table/WithdrawCard.jsx +++ b/app/components/table/WithdrawCard.jsx @@ -12,10 +12,12 @@ import indigo from '@material-ui/core/colors/indigo' import blueGrey from '@material-ui/core/colors/blueGrey' import Collapse from '@material-ui/core/Collapse' import LiquidPledgingMock from 'Embark/contracts/LiquidPledgingMock' +import LPVault from 'Embark/contracts/LPVault' import { getTokenLabel } from '../../utils/currencies' import { toWei } from '../../utils/conversions' const { withdraw } = LiquidPledgingMock.methods +const { confirmPayment } = LPVault.methods const styles = { card: { @@ -54,13 +56,15 @@ class Withdraw extends PureComponent { render() { const { classes, rowData } = this.props const { show } = this.state + const isPaying = rowData[7] === "1" return ( { const { amount } = values - const args = [rowData.id, toWei(amount)] - withdraw(...args) + const args = isPaying ? [rowData.id] : [rowData.id, toWei(amount)] + const sendFn = isPaying ? confirmPayment : withdraw + sendFn(...args) .send() .then(res => { console.log({res}) @@ -88,10 +92,10 @@ class Withdraw extends PureComponent {
- - {`Withdraw ${values.amount || ''} ${values.amount ? getTokenLabel(rowData[6]) : ''} from Pledge ${rowData.id}`} + + {`${isPaying ? 'Confirm' : ''} Withdraw${isPaying ? 'al' : ''} ${values.amount || ''} ${values.amount ? getTokenLabel(rowData[6]) : ''} from Pledge ${rowData.id}`} - + />} - - + +
diff --git a/test/NormalOperation.js b/test/NormalOperation.js index c3d5d70..e41b869 100644 --- a/test/NormalOperation.js +++ b/test/NormalOperation.js @@ -306,7 +306,7 @@ describe('LiquidPledging test', function() { assert.equal(res7.commitTime, 0); assert.equal(res7.oldPledge, 2); assert.equal(res7.token, giver1Token.$address); - assert.equal(res7.pledgeState, 2); // Pending + assert.equal(res7.pledgeState, 2); // Paid }); it('Admin of the project1 should be able to cancel project1', async () => { await liquidPledging.cancelProject(3, { from: adminProject1, $extraGas: 100000 });