From 69a952d94a9a43186209846acba96b53c47a3d3b Mon Sep 17 00:00:00 2001 From: Barry Gitarts Date: Thu, 31 May 2018 13:29:42 -0400 Subject: [PATCH] add handleSubmit and FieldGroups --- .../proposal-manager/proposal-manager.js | 123 ++++++++++-------- 1 file changed, 67 insertions(+), 56 deletions(-) diff --git a/app/components/proposal-manager/proposal-manager.js b/app/components/proposal-manager/proposal-manager.js index 21a0615..cbb6cf1 100644 --- a/app/components/proposal-manager/proposal-manager.js +++ b/app/components/proposal-manager/proposal-manager.js @@ -85,74 +85,85 @@ class InnerForm extends Component { } - render(){ + render() { const { values, errors, touched, handleChange, handleBlur, handleSubmit, isSubmitting, setFieldValue } = this.props; const { canSubmit } = this.state; return ( - {canSubmit && - - Account not allowed to submit proposals - - } -

Add proposal

-

Execute this on the console if proposal submit is not allowed

- await ProposalCuration.methods.setSubmitPrice(web3.eth.defaultAccount, true, 1).send(); -

Price: {this.state.submitPrice}

-
- - - - - - - - - - - { - this.state.canSubmit ? - - - - : '' + {!canSubmit && + + Account not allowed to submit proposals + } - +

Add proposal

+

Execute this on the console if proposal submit is not allowed

+ await ProposalCuration.methods.setSubmitPrice(web3.eth.defaultAccount, true, 1).send(); +

Price: {this.state.submitPrice}

+
+ + + + +
) } } const ProposalManager = withFormik({ - mapPropsToValues: props => ({ title: '' }), + mapPropsToValues: props => ({ title: '', description: '', url: '' }), validate(values) {}, - handleSubmit(values, { setSubmitting}){} + handleSubmit(values, { setSubmitting}){ + const { title, description, url } = values; + const { saveText } = EmbarkJS.Storage; + const { toHex } = web3.utils; + const { submitProposal } = ProposalCuration.methods; + saveText(JSON.stringify(description)) + .then(hash => { + const hexHash = toHex(hash); + //TODO create toggle for address approval + submitProposal( + "0x00", + "0x0000000000000000000000000000000000000000", + 0, + "0x00", + hexHash + ) + .send({from: web3.eth.defaultAccount, gasLimit: 1000000}) + .then(res => { + setSubmitting(false); + console.log(res); + }) + .catch(err => { + setSubmitting(false); + console.log('Storage saveText Error: ', err.message) + }); + }) + } })(InnerForm) export default ProposalManager;