diff --git a/app/components/proposal-manager/proposal-manager.js b/app/components/proposal-manager/proposal-manager.js index ea71b7c..618ce82 100644 --- a/app/components/proposal-manager/proposal-manager.js +++ b/app/components/proposal-manager/proposal-manager.js @@ -1,8 +1,9 @@ import EmbarkJS from 'Embark/EmbarkJS'; import ERC20Token from 'Embark/contracts/ERC20Token'; -import ProposalCuration from 'Embark/contracts/ProposalCuration' +import ProposalCuration from 'Embark/contracts/ProposalCuration'; +import SNT from 'Embark/contracts/SNT'; import React, { Fragment } from 'react'; -import { Form, FormGroup, FormControl, HelpBlock, Button } from 'react-bootstrap'; +import { Form, FormGroup, FormControl, HelpBlock, Button, Alert } from 'react-bootstrap'; import web3 from "Embark/web3" class ProposalManager extends React.Component { @@ -11,13 +12,11 @@ class ProposalManager extends React.Component { super(props); this.state = { submitPrice: "Loading...", - to: "", - value: "", - data: "", + url: "", + title: "", description: "", - topic: "0x00" + canSubmit: true }; - window['ProposalCuration'] = ProposalCuration; } componentDidMount(){ @@ -33,67 +32,96 @@ class ProposalManager extends React.Component { try { let _b = await ProposalCuration.methods.getSubmitPrice(web3.eth.defaultAccount).call(); this.setState({ - balance: _b + submitPrice: _b, + canSubmit: true }); } catch(err){ - console.log("Couldn't get submit price") + this.setState({ + canSubmit: false, + submitPrice: "-" + }); } }); } + async handleClick(){ + let description = { + "url": this.state.url, + "title": this.state.title, + "description": this.state.description + }; + + let hexDescription = web3.utils.toHex(JSON.stringify(description)); + + let receipt = await SNT.methods.approve( + ProposalCuration.options.address, + this.state.submitPrice) + .send({from: web3.eth.defaultAccount, gasLimit: 1000000}); + + console.log(receipt); + + receipt = await ProposalCuration.methods.submitProposal( + "0x00", + "0x0000000000000000000000000000000000000000", + 0, + "0x00", + hexDescription + ) + .send({from: web3.eth.defaultAccount, gasLimit: 1000000}); + + console.log(receipt); + } + + render(){ return ( -

Add

-

Price for submitting proposals: {this.state.submitPrice}

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

Add proposal

+

Price: {this.state.submitPrice}

- - - - - - - - - - - - - - - + + + + + + + + + + { + this.state.canSubmit ? + + + + : '' + }
-
+ ) } } diff --git a/app/components/voting-dapp/proposal-form.js b/app/components/voting-dapp/proposal-form.js index 58d4a95..e1929c6 100644 --- a/app/components/voting-dapp/proposal-form.js +++ b/app/components/voting-dapp/proposal-form.js @@ -1,6 +1,7 @@ import web3 from "Embark/web3" import EmbarkJS from 'Embark/EmbarkJS'; import React from 'react'; +import { Button } from 'react-bootstrap'; class ProposalForm extends React.Component { @@ -9,8 +10,16 @@ class ProposalForm extends React.Component { this.state = {}; } + handleClick(e){ + e.preventDefault(); + + + } + render(){ - return
TODO: Form
; + return
+ +
; } } diff --git a/app/components/voting-dapp/proposal.js b/app/components/voting-dapp/proposal.js index 51e4b5d..5597217 100644 --- a/app/components/voting-dapp/proposal.js +++ b/app/components/voting-dapp/proposal.js @@ -1,6 +1,6 @@ import React from 'react'; import $ from 'jquery'; -import {Button} from 'react-bootstrap'; +import { Button, Alert } from 'react-bootstrap'; import EmbarkJS from 'Embark/EmbarkJS'; import ProposalForm from './proposal-form'; @@ -12,7 +12,8 @@ class Proposal extends React.Component { this.state = { url: null, title: null, - description: null + description: null, + error: null }; } @@ -29,7 +30,6 @@ class Proposal extends React.Component { }) .catch((err) => { if(err){ - // TODO handle error console.log("Storage get Error => " + err.message); } }); @@ -38,6 +38,13 @@ class Proposal extends React.Component { render(){ return (
+ { + this.state.error !== null ? + + { this.state.error } + + : '' + }

{ this.state.title }

{ this.state.description }

{ this.state.url } diff --git a/app/components/voting-dapp/voting-dapp.js b/app/components/voting-dapp/voting-dapp.js index 4cbeebd..d8271a1 100644 --- a/app/components/voting-dapp/voting-dapp.js +++ b/app/components/voting-dapp/voting-dapp.js @@ -19,7 +19,6 @@ class VotingDapp extends React.Component { return
-
; }