Add redirect to the tournament after successful creation

This commit is contained in:
Jonny 2019-06-18 14:23:44 +02:00
parent 4f9942e242
commit f99492c809
2 changed files with 4 additions and 3 deletions

View File

@ -182,7 +182,7 @@ const reducerTournamentinfo = (state = defaultStateTournamentinfo, action) => {
case actionTypesTournamentinfo.CREATE_TOURNAMENT: case actionTypesTournamentinfo.CREATE_TOURNAMENT:
postRequest(action.state, '/tournaments', action.parameters.tournament).then(resp => { postRequest(action.state, '/tournaments', action.parameters.tournament).then(resp => {
storeOptionalToken(resp); storeOptionalToken(resp);
action.parameters.successCallback(); action.parameters.successCallback(resp.data);
}).catch(error => { }).catch(error => {
if (error.response) { if (error.response) {
storeOptionalToken(error.response); storeOptionalToken(error.response);

View File

@ -21,6 +21,7 @@ import {Footer} from '../js/components/Footer';
import EditableStringList from '../js/components/EditableStringList'; import EditableStringList from '../js/components/EditableStringList';
import {createTournament} from '../js/api'; import {createTournament} from '../js/api';
import {WarningPopup} from '../js/components/WarningPopup'; import {WarningPopup} from '../js/components/WarningPopup';
import Router from 'next/router';
import '../static/css/everypage.css'; import '../static/css/everypage.css';
import RequireLogin from '../js/components/RequireLogin'; import RequireLogin from '../js/components/RequireLogin';
@ -216,8 +217,8 @@ class CreateTournamentForm extends React.Component {
create() { create() {
if (this.valuesAreCredible()) { if (this.valuesAreCredible()) {
createTournament(this.generateTournamentCreationObject(), () => { createTournament(this.generateTournamentCreationObject(), data => {
notify.show('Das Turnier wurde erfolgreich erstellt.', 'success', 5000); Router.push('/t/' + data.id);
}, () => { }, () => {
notify.show('Das Turnier konnte nicht erstellt werden.', 'warning', 5000); notify.show('Das Turnier konnte nicht erstellt werden.', 'warning', 5000);
}); });