import React from 'react' import { Formik } from 'formik' import LiquidPledgingMock from 'Embark/contracts/LiquidPledgingMock' import Button from '@material-ui/core/Button' import TextField from '@material-ui/core/TextField' import Dialog from '@material-ui/core/Dialog' import DialogActions from '@material-ui/core/DialogActions' import DialogContent from '@material-ui/core/DialogContent' import DialogContentText from '@material-ui/core/DialogContentText' import DialogTitle from '@material-ui/core/DialogTitle' import { getTokenLabel } from '../utils/currencies' import { toWei } from '../utils/conversions' import { FundingContext } from '../context' const { transfer } = LiquidPledgingMock.methods const TransferDialog = ({ row, handleClose, transferPledgeAmounts }) => ( { const { owner, id } = row const { amount, idReceiver } = values const args = [owner, id, toWei(amount.toString()), idReceiver] transfer(...args) .send() .then(res => { console.log({res}) const { events: { Transfer: { returnValues } } } = res transferPledgeAmounts(returnValues) handleClose() }) .catch(e => { console.log({e}) }) .finally(() => { resetForm() }) }} > {({ values, errors, touched, handleChange, handleBlur, handleSubmit, submitForm, setFieldValue, setStatus, status }) => (
Transfer Funds {`Transfer ${values.amount || ''} ${values.amount ? getTokenLabel(row[6]) : ''} from Pledge ${row.id} ${values.idReceiver ? 'to Giver/Delegate/Project' : ''} ${values.idReceiver || ''}`}
)}
) export default TransferDialog