[VIEW] fix minor details

pull/73/head
Pierre-Louis Guhur 4 years ago
parent cd3425aa66
commit af79b633dd

@ -256,6 +256,8 @@ class CreateElection extends Component {
this.context.routesServer.setElection, this.context.routesServer.setElection,
); );
const {t} = this.props;
this.setState({waiting: true}); this.setState({waiting: true});
fetch(endpoint, { fetch(endpoint, {
@ -274,13 +276,22 @@ class CreateElection extends Component {
}), }),
}) })
.then(response => response.json()) .then(response => response.json())
.then(result => .then(result => {
this.setState(state => ({ console.log(result);
redirectTo: '/create-success/' + result.id, if (result.id) {
successCreate: true, this.setState(state => ({
waiting: false redirectTo: '/create-success/' + result.id,
})), successCreate: true,
) waiting: false
}))
}
else {
toast.error(t('Unknown error. Try again please.'), {
position: toast.POSITION.TOP_CENTER,
});
this.setState({waiting: false});
}
})
.catch(error => error); .catch(error => error);
} }

@ -200,7 +200,7 @@ class Result extends Component {
<li key={i} className="mt-2"> <li key={i} className="mt-2">
<span className="mt-2 ml-2">{candidate.name}</span> <span className="mt-2 ml-2">{candidate.name}</span>
<span <span
className="badge badge-light mr-2 mt-2" className="badge badge-light ml-2 mt-2"
style={{ style={{
backgroundColor: electionGrades[candidate.grade].color, backgroundColor: electionGrades[candidate.grade].color,
color: "#fff" color: "#fff"
@ -208,7 +208,7 @@ class Result extends Component {
> >
{grades[candidate.grade].label} {grades[candidate.grade].label}
</span> </span>
<span className="badge badge-dark mr-2 mt-2 ml-2"> <span className="badge badge-dark mt-2 ml-2">
{(100 * candidate.score).toFixed(1)}% {(100 * candidate.score).toFixed(1)}%
</span> </span>
</li> </li>

Loading…
Cancel
Save