diff --git a/js/api.js b/js/api.js
index d3b9b10..83f281b 100644
--- a/js/api.js
+++ b/js/api.js
@@ -396,6 +396,10 @@ export function updateTeamName(team, successCB, errorCB) {
});
}
+export function getState() {
+ return __store.getState();
+}
+
function rehydrateApplicationState() {
const persistedState = localStorage.getItem('reduxState') ?
JSON.parse(localStorage.getItem('reduxState')) :
diff --git a/pages/tournament.js b/pages/tournament.js
index c3905a6..40753f5 100644
--- a/pages/tournament.js
+++ b/pages/tournament.js
@@ -31,31 +31,25 @@ import {
class TournamentPage extends React.Component {
- static async getInitialProps({query}) {
- return {query};
- }
-
- componentDidMount() {
- verifyCredentials();
- }
-
render() {
+ const { id, description, isPublic, code, ownerUsername, playoffStages } = this.props.tournament;
+
// TODO: Change href-prop of the anchor tag to contain the tournament code
return (
- Turnier bearbeiten
- {props.tournament.description}
+ Turnier bearbeiten
+ {description}
- {props.tournament.isPublic ? 'Das Turnier ist öffentlich.' : 'Das Turnier ist privat.'}
+ {isPublic ? 'Das Turnier ist öffentlich.' : 'Das Turnier ist privat.'}
- Turnier-Code: {props.tournament.code}
- von {props.tournament.ownerUsername}
+ Turnier-Code: {code}
+ von {ownerUsername}
- {props.tournament.playoffStages.map(stage =>
+ {playoffStages.map(stage =>
)}
@@ -73,10 +67,12 @@ function getLevelName(levelNumber) {
}
function TournamentContainer(props) {
- if (props.data === null) {
+ const { tournament } = props.data;
+
+ if (tournament === null) {
return null;
} else {
- return ;
+ return ;
}
}
@@ -355,9 +351,24 @@ function convertMatch(apiMatch) {
}
class Main extends React.Component {
+
+ static async getInitialProps({query}) {
+ return {query};
+ }
+
constructor(props) {
super(props);
+
+ this.state = {
+ tournament : null
+ };
+ }
+
+ componentDidMount() {
+ verifyCredentials();
+
const code = this.props.query.code;
+
getRequest(getState(), '/tournaments/' + code)
.then(response => {
this.setState({tournament: convertTournament(response.data)});
@@ -365,8 +376,9 @@ class Main extends React.Component {
.catch(() => { /* TODO: Show some kind of error or smth */ });
}
+
render() {
- const tournamentName = this.state === null ? 'Turnier' : this.state.tournament.name;
+ const tournamentName = this.state.tournament === null ? 'Turnier' : this.state.tournament.name;
return (