add initial form scafold for proposal manager

This commit is contained in:
Barry Gitarts 2018-05-31 09:53:26 -04:00
parent eec4518aa3
commit 9e010a79c2
4 changed files with 158 additions and 113 deletions

4
.babelrc Normal file
View File

@ -0,0 +1,4 @@
{
"plugins": ["transform-object-rest-spread"],
"presets": ["stage-2"]
}

View File

@ -4,9 +4,12 @@ import ProposalCuration from 'Embark/contracts/ProposalCuration';
import SNT from 'Embark/contracts/SNT'; import SNT from 'Embark/contracts/SNT';
import React, { Component, Fragment } from 'react'; import React, { Component, Fragment } from 'react';
import { Form, FormGroup, FormControl, HelpBlock, Button, Alert } from 'react-bootstrap'; import { Form, FormGroup, FormControl, HelpBlock, Button, Alert } from 'react-bootstrap';
import web3 from "Embark/web3" import web3 from "Embark/web3";
import { withFormik } from 'formik';
import FieldGroup from '../standard/FieldGroup';
class ProposalManager extends Component { //TODO make innerform and wrap
class InnerForm extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
@ -83,14 +86,14 @@ class ProposalManager extends Component {
render(){ render(){
const { values, errors, touched, handleChange, handleBlur, handleSubmit, isSubmitting, setFieldValue } = this.props;
const { canSubmit } = this.state;
return ( return (
<Fragment> <Fragment>
{ {canSubmit &&
!this.state.canSubmit ?
<Alert bsStyle="warning"> <Alert bsStyle="warning">
Account not allowed to submit proposals Account not allowed to submit proposals
</Alert> </Alert>
: ''
} }
<h2>Add proposal</h2> <h2>Add proposal</h2>
<p>Execute this on the console if proposal submit is not allowed</p> <p>Execute this on the console if proposal submit is not allowed</p>
@ -106,6 +109,15 @@ class ProposalManager extends Component {
onChange={(e) => this.setState({title: e.target.value }) } /> onChange={(e) => this.setState({title: e.target.value }) } />
</label> </label>
</FormGroup> </FormGroup>
<FieldGroup
id="title"
name="title"
type="test"
label="Title"
onChange={handleChange}
onBlur={handleBlur}
value={values.title}
/>
<FormGroup> <FormGroup>
<label> <label>
Description: Description:
@ -137,4 +149,10 @@ class ProposalManager extends Component {
} }
} }
const ProposalManager = withFormik({
mapPropsToValues: props => ({ title: '' }),
validate(values) {},
handleSubmit(values, { setSubmitting}){}
})(InnerForm)
export default ProposalManager; export default ProposalManager;

View File

@ -0,0 +1,20 @@
import React from 'react';
import { FormGroup, FormControl, HelpBlock, ControlLabel, InputGroup } from 'react-bootstrap';
const FieldGroup = ({ id, label, button, error, ...props }) => (
<FormGroup controlId={id} validationState={error ? 'error' : null}>
<ControlLabel>{label}</ControlLabel>
{button
? <InputGroup>
<InputGroup.Button>
{button}
</InputGroup.Button>
<FormControl {...props} />
</InputGroup>
: <FormControl {...props} />
}
{error && <HelpBlock>{error}</HelpBlock>}
</FormGroup>
)
export default FieldGroup;

View File

@ -17,6 +17,9 @@
}, },
"homepage": "https://github.com/status-im/contracts#readme", "homepage": "https://github.com/status-im/contracts#readme",
"dependencies": { "dependencies": {
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-stage-2": "^6.24.1",
"formik": "^0.11.11",
"jquery": "^3.3.1", "jquery": "^3.3.1",
"react": "^16.3.2", "react": "^16.3.2",
"react-blockies": "^1.3.0", "react-blockies": "^1.3.0",