diff --git a/app/components/PledgesTable.jsx b/app/components/PledgesTable.jsx index 91c59ae..6ac5eea 100644 --- a/app/components/PledgesTable.jsx +++ b/app/components/PledgesTable.jsx @@ -68,15 +68,13 @@ class PledgesTable extends Component { } handleClose = () => { - this.setState({ row: false }) + this.setState({ rowData: null }) } - clearRowData = () => this.setState({ rowData: null }) - render() { - const { data, row, rowData } = this.state + const { data, rowData } = this.state return ( - +
{ - this.handleClickOpen(rowData) + const { timeStamp } = event + this.setState({ + rowData: { ...rowData, timeStamp, type: 'transfer' } + }) } }, { @@ -106,16 +107,16 @@ class PledgesTable extends Component { const { timeStamp } = event console.log({rowData}) this.setState({ - rowData: { ...rowData, timeStamp } + rowData: { ...rowData, timeStamp, type: 'withdraw' } }) } } ]} /> - {!rowData &&
} - {rowData && } - {row && } - + {!rowData &&
} + {rowData && rowData.type === 'withdraw' && } + {rowData && rowData.type === 'transfer' && } +
) } } diff --git a/app/components/table/CardStyles.js b/app/components/table/CardStyles.js index 1cabd46..7f469f4 100644 --- a/app/components/table/CardStyles.js +++ b/app/components/table/CardStyles.js @@ -8,9 +8,6 @@ const styles = { borderBottom: '1px solid lightgray', backgroundColor: indigo[50] }, - container: { - height: '35%' - }, bullet: { display: 'inline-block', margin: '0 2px', diff --git a/app/components/table/TransferCard.jsx b/app/components/table/TransferCard.jsx index 3ccb67f..0565f93 100644 --- a/app/components/table/TransferCard.jsx +++ b/app/components/table/TransferCard.jsx @@ -38,27 +38,27 @@ function TransferCard({ row, handleClose, classes }) { const estimatedGas = await toSend.estimateGas() toSend - .send({gas: estimatedGas + 1000}) - .then(async res => { - console.log({res}) - const { events: { Transfer } } = res - if (Array.isArray(Transfer)) { - Transfer.forEach(async t => { - const { to, amount } = t.returnValues - await pledge.transferTo(to, amount) - }) - } else { - const { to, amount } = Transfer.returnValues - await pledge.transferTo(to, amount) - } - }) - .catch(e => { - console.log({e}) - }) - .finally(() => { - close() - resetForm() - }) + .send({gas: estimatedGas + 1000}) + .then(async res => { + console.log({res}) + const { events: { Transfer } } = res + if (Array.isArray(Transfer)) { + Transfer.forEach(async t => { + const { to, amount } = t.returnValues + await pledge.transferTo(to, amount) + }) + } else { + const { to, amount } = Transfer.returnValues + await pledge.transferTo(to, amount) + } + }) + .catch(e => { + console.log({e}) + }) + .finally(() => { + close() + resetForm() + }) }} > {({ @@ -73,7 +73,7 @@ function TransferCard({ row, handleClose, classes }) { setStatus, status }) => ( - +
diff --git a/app/components/table/WithdrawCard.jsx b/app/components/table/WithdrawCard.jsx index d081469..d1fd9cb 100644 --- a/app/components/table/WithdrawCard.jsx +++ b/app/components/table/WithdrawCard.jsx @@ -21,7 +21,7 @@ import styles from './CardStyles' const { withdraw } = LiquidPledging.methods const { confirmPayment } = LPVault.methods -function Withdraw({ clearRowData, classes, rowData, authorizedPayment }) { +function Withdraw({ handleClose, classes, rowData, authorizedPayment }) { const [show, setShow] = useState(null) const [rowId, setRowId] = useState(rowData.pledgeId) @@ -38,7 +38,7 @@ function Withdraw({ clearRowData, classes, rowData, authorizedPayment }) { const close = () => { setShow(false) - setTimeout(() => { clearRowData() }, 500) + setTimeout(() => { handleClose() }, 500) } const isPaying = rowData.pledgeState === 'Paying' @@ -53,16 +53,17 @@ function Withdraw({ clearRowData, classes, rowData, authorizedPayment }) { try { const toSend = sendFn(...args) const estimateGas = await toSend.estimateGas() - toSend.send({ gas: estimateGas + 1000 }) - .then(res => { - console.log({res}) - }) - .catch(e => { - console.log({e}) - }) - .finally(() => { - close() - }) + toSend + .send({ gas: estimateGas + 1000 }) + .then(res => { + console.log({res}) + }) + .catch(e => { + console.log({e}) + }) + .finally(() => { + close() + }) } catch (error) { console.log(error) } @@ -114,7 +115,7 @@ function Withdraw({ clearRowData, classes, rowData, authorizedPayment }) { Withdraw.propTypes = { classes: PropTypes.object.isRequired, rowData: PropTypes.object.isRequired, - clearRowData: PropTypes.func.isRequired, + handleClose: PropTypes.func.isRequired, authorizedPayment: PropTypes.array.isRequired }