Send title from Home to CreateBallot page

pull/4/head
Clement G 5 years ago committed by guhur
parent 79570c9017
commit 5ea4f73c4a

@ -11,6 +11,9 @@ class CreateBallot extends Component {
} }
render(){ render(){
const params = new URLSearchParams(this.props.location.search);
return( return(
<Container> <Container>
<Row> <Row>
@ -18,7 +21,7 @@ class CreateBallot extends Component {
</Row> </Row>
<Row className="mt-2"> <Row className="mt-2">
<Col xs="12" > <Col xs="12" >
<Input placeholder="Saisissez ici la question de votre vote" name="title" /> <Input placeholder="Saisissez ici la question de votre vote" name="title" autoFocus defaultValue={params.get("title")?params.get("title"):""} />
</Col> </Col>
</Row> </Row>
</Container> </Container>

@ -12,7 +12,7 @@ class Home extends Component {
this.state = { this.state = {
title:null, title:null,
redirect:false, redirect:false,
} };
} }
handleSubmit = (event) => { handleSubmit = (event) => {
@ -21,7 +21,7 @@ class Home extends Component {
}; };
handleChangeTitle= (event) => { handleChangeTitle= (event) => {
this.setState({title: event.target.value}); this.setState({title: event.target.value});
}; };
render(){ render(){
@ -41,7 +41,7 @@ class Home extends Component {
</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" name="title" value={this.state.title} onChange={this.handleChangeTitle} /> <Input placeholder="Saisissez ici la question de votre vote" autoFocus required className="mt-2" name="title" value={this.state.title?this.state.title:""} onChange={this.handleChangeTitle} />
</Col> </Col>
<Col xs="12" md="3" xl="2"> <Col xs="12" md="3" xl="2">
<Button type="submit" 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>

Loading…
Cancel
Save