|
|
@ -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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|