From c880b3a272786cdd9eb4f22110a9ac45a4558885 Mon Sep 17 00:00:00 2001 From: Damien <damien.armillon@gmail.com> Date: Sun, 5 May 2019 13:14:40 +0200 Subject: [PATCH] On refresh quand il faut --- front/src/App.js | 4 ++-- front/src/FormToucan.js | 7 ++----- front/src/ModalSuppression.js | 3 ++- front/src/ToucanTable.js | 6 ++---- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/front/src/App.js b/front/src/App.js index 0a67227..03bafa9 100644 --- a/front/src/App.js +++ b/front/src/App.js @@ -10,8 +10,8 @@ function App() { <Segment padded style={{margin:"3%"}}> <FormToucan /> </Segment> - <Segment textAlign="center" padded style={{margin:"3%"}}> - <ToucanTable/> + <Segment textAlign="center" padded style={{margin:"3%"}} > + <ToucanTable /> </Segment> </div> ); diff --git a/front/src/FormToucan.js b/front/src/FormToucan.js index 64c713c..a5442ce 100644 --- a/front/src/FormToucan.js +++ b/front/src/FormToucan.js @@ -31,7 +31,6 @@ class FormToucan extends Component { } onToucanChange = (e) => { - console.log(e.target); const file = e.target.files[0]; if (file.type === 'application/pdf') { // Si on a bien un pdf @@ -50,7 +49,7 @@ class FormToucan extends Component { onDateChange = (event,{value}) =>{ let [day,month,year] = value.split("-") - this.setState({date: new Date(Date.UTC(year,month-1,day,0,0,0))},()=> console.log(this.state.date.toLocaleDateString())); + this.setState({date: new Date(Date.UTC(year,month-1,day,0,0,0))}); } onSubmit = () => { @@ -66,12 +65,11 @@ class FormToucan extends Component { method: 'POST', body: form }) - .then((msg)=>console.log(msg)) + .then(() => window.location.reload()) .catch((err)=>console.log(err)) } render() { - const errorMessage = []; if (this.state.titleError) { errorMessage.push("Le thème doit faire entre 1 et 60 caractères, les caractères spéciaux ($ € { } [ ] ... ) ne sont pas autorisés") @@ -122,7 +120,6 @@ class FormToucan extends Component { {errorMessage.map((err) => {return <li>{err}</li>})} </ul> } /> - <Form.Button disabled={formError} content="C'est parti !" /> </Form> ) diff --git a/front/src/ModalSuppression.js b/front/src/ModalSuppression.js index 424c114..0a75ae1 100644 --- a/front/src/ModalSuppression.js +++ b/front/src/ModalSuppression.js @@ -7,7 +7,8 @@ class ModalSupression extends Component { fetch(`${env.backURL}/toucan/delete/${id}`,{ method: "Post" }) - .then(this.props.closeModal()) + .then(() => window.location.reload()) + .catch(err => console.log(err)) } render() { diff --git a/front/src/ToucanTable.js b/front/src/ToucanTable.js index 7780444..39d2841 100644 --- a/front/src/ToucanTable.js +++ b/front/src/ToucanTable.js @@ -14,14 +14,12 @@ class ToucanTable extends Component{ componentDidMount(){ fetch(`${env.backURL}/toucan/toucans`) .then(result => { - console.log(result) return result.json() }) .then(toucans => { - console.log(toucans) - this.setState({toucans}) + this.setState({toucans}) }) - .catch(err => console.log(err)) + .catch(err => console.log(err)) } render() { -- GitLab