Try to send title from Home to CreateBallot page

pull/4/head
Clement G 5 years ago committed by guhur
parent f06482f856
commit 531d6f1584

@ -1,4 +1,6 @@
import React, {Component} from "react"; import React, {Component} from "react";
import { Container, Row, Col, Input } from 'reactstrap';
class CreateBallot extends Component { class CreateBallot extends Component {
@ -10,9 +12,16 @@ class CreateBallot extends Component {
render(){ render(){
return( return(
<div > <Container>
<h1>View : CREATE BALLOT</h1> <Row>
</div> <Col ><h3>Formulaire :</h3></Col>
</Row>
<Row className="mt-2">
<Col xs="12" >
<Input placeholder="Saisissez ici la question de votre vote" name="title" />
</Col>
</Row>
</Container>
) )
} }
} }

@ -1,33 +1,52 @@
import React, {Component} from "react"; import React, {Component} from "react";
import { Container, Row, Col,Button, Input } from 'reactstrap'; import { Container, Row, Col,Button, Input } from 'reactstrap';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faRocket } from '@fortawesome/free-solid-svg-icons' import { faRocket } from '@fortawesome/free-solid-svg-icons';
import { Redirect } from 'react-router-dom';
class Home extends Component { class Home extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
title:null,
redirect:false,
} }
} }
handleSubmit = (event) => {
event.preventDefault();
this.setState({redirect: true});
};
handleChangeTitle= (event) => {
this.setState({title: event.target.value});
};
render(){ render(){
const redirect = this.state.redirect;
if (redirect) {
return <Redirect to={ '/create-ballot/?title='+encodeURIComponent(this.state.title)} />;
}
return( return(
<Container> <Container>
<form ref="form" onSubmit={this.handleSubmit}>
<Row> <Row>
<Col className="text-center"><h3>Simple et gratuit : organisez un vote à l'aide du Jugement Majoritaire.</h3></Col> <Col className="text-center"><h3>Simple et gratuit : organisez un vote à l'aide du Jugement Majoritaire.</h3></Col>
</Row> </Row>
<Row className="mt-2"> <Row className="mt-2">
<Col xs="12" md="9" xl="6" className="offset-xl-2"> <Col xs="12" md="9" xl="6" className="offset-xl-2">
<Input placeholder="Saisissez ici la question de votre vote" className="mt-2" /> <Input placeholder="Saisissez ici la question de votre vote" className="mt-2" name="title" value={this.state.title} onChange={this.handleChangeTitle} />
</Col> </Col>
<Col xs="12" md="3" xl="2"> <Col xs="12" md="3" xl="2">
<Button className="btn btn-block btn-secondary mt-2"><FontAwesomeIcon icon={faRocket} className="mr-2"/>Lancer</Button> <Button type="submit" className="btn btn-block btn-secondary mt-2" ><FontAwesomeIcon icon={faRocket} className="mr-2"/>Lancer</Button>
</Col> </Col>
</Row> </Row>
<Row className="mt-4"> <Row className="mt-4">
<Col className="text-center"><p>Pas de publicité et pas de cookie publicitaire.</p></Col> <Col className="text-center"><p>Pas de publicité et pas de cookie publicitaire.</p></Col>
</Row> </Row>
</form>
</Container> </Container>
) )
} }

Loading…
Cancel
Save