}
}
class Main extends React.Component {
constructor(props) {
super(props);
const code = this.props.query.code;
getRequest('/tournaments/' + code, {})
.then(response => {
const attributes = response.data.data.attributes;
const relationships = response.data.data.relationships;
this.setState({
tournament: {
name: attributes.name,
code: attributes.code,
description: attributes.description,
isPublic: attributes.public,
teams: relationships.teams.data.map(team => team.id),
stages: relationships.stages.data.map(stage => stage.id)
}
});
})
.catch(error => console.log(error));
}
static async getInitialProps({query}) {
return {query}
}
render() {
const tournamentName = this.state === null ? 'Turnier' : this.state.tournament.name;
return (
{tournamentName}: turnie.re
{JSON.stringify(this.state)}
);
}
}
export default Main