convert hoursToSeconds

cleanup AddFunder
This commit is contained in:
Barry Gitarts 2018-11-30 11:52:08 -05:00
parent 4118da3081
commit a1d116c7a2
1 changed files with 8 additions and 10 deletions

View File

@ -1,7 +1,5 @@
import React from 'react'; import React from 'react';
import { Formik } from 'formik'; import { Formik } from 'formik';
import EmbarkJS from 'Embark/EmbarkJS';
import LPVault from 'Embark/contracts/LPVault';
import LiquidPledgingMock from 'Embark/contracts/LiquidPledgingMock'; import LiquidPledgingMock from 'Embark/contracts/LiquidPledgingMock';
import Button from '@material-ui/core/Button'; import Button from '@material-ui/core/Button';
import TextField from '@material-ui/core/TextField'; import TextField from '@material-ui/core/TextField';
@ -9,20 +7,20 @@ import Snackbar from '@material-ui/core/Snackbar';
import web3 from "Embark/web3"; import web3 from "Embark/web3";
import { MySnackbarContentWrapper } from './base/SnackBars'; import { MySnackbarContentWrapper } from './base/SnackBars';
const { addGiver, numberOfPledgeAdmins, getPledgeAdmin } = LiquidPledgingMock.methods; const { addGiver } = LiquidPledgingMock.methods
const hoursToSeconds = hours => hours * 60 * 60; const hoursToSeconds = hours => hours * 60 * 60
const addFunderSucessMsg = response => { const addFunderSucessMsg = response => {
const { events: { GiverAdded: { returnValues: { idGiver } } } } = response; const { events: { GiverAdded: { returnValues: { idGiver } } } } = response
return `Funder created with ID of ${idGiver}`; return `Funder created with ID of ${idGiver}`
} }
const AddFunder = () => ( const AddFunder = () => (
<Formik <Formik
initialValues={{ funderName: '', funderDescription: '', commitTime : '' }} initialValues={{ funderName: '', funderDescription: '', commitTime : '' }}
onSubmit={async (values, { setSubmitting, resetForm, setStatus }) => { onSubmit={async (values, { setSubmitting, resetForm, setStatus }) => {
const { funderName, funderDescription, commitTime } = values; const { funderName, funderDescription, commitTime } = values
const account = await web3.eth.getCoinbase(); const account = await web3.eth.getCoinbase()
const args = [funderName, funderDescription, commitTime, 0]; const args = [funderName, funderDescription, hoursToSeconds(commitTime), 0]
addGiver(...args) addGiver(...args)
.estimateGas({ from: account }) .estimateGas({ from: account })
.then(async gas => { .then(async gas => {
@ -112,4 +110,4 @@ const AddFunder = () => (
</Formik> </Formik>
) )
export default AddFunder; export default AddFunder