diff --git a/pages/tournament.js b/pages/tournament.js index 1b12687..343192f 100644 --- a/pages/tournament.js +++ b/pages/tournament.js @@ -35,16 +35,17 @@ import 'bootstrap/dist/css/bootstrap.min.css'; import '../static/everypage.css'; import '../static/css/tournament.css'; -class TournamentPage extends React.Component { +class PrivateTournamentPage extends React.Component { render() { const { id, description, isPublic, code, ownerUsername, playoffStages } = this.props.tournament; + const { isSignedIn, username } = this.props; // TODO: Change href-prop of the anchor tag to contain the tournament code return (
- +

{description}

@@ -56,14 +57,23 @@ class TournamentPage extends React.Component {
{playoffStages.map(stage => - )} + )}
); } } -function PrivateEditButton(props) { +function mapStateToTournamentPageProperties(state) { + const { isSignedIn, username } = state.userinfo; + return { isSignedIn, username }; +} + +const TournamentPage = connect( + mapStateToTournamentPageProperties +)(PrivateTournamentPage); + +function EditButton(props) { const { id, ownerName, isSignedIn, username } = props; if(isSignedIn && ownerName === username) { @@ -75,15 +85,6 @@ function PrivateEditButton(props) { } } -function mapStateToEditButtonProperties(state) { - const { isSignedIn, username } = state.userinfo; - return { isSignedIn, username }; -} - -const EditButton = connect( - mapStateToEditButtonProperties -)(PrivateEditButton); - function getLevelName(levelNumber) { const names = ['Finale', 'Halbfinale', 'Viertelfinale', 'Achtelfinale']; if(levelNumber < names.length){ @@ -116,7 +117,11 @@ class Match extends React.Component { } toggleModal() { - this.setState({modal: !this.state.modal}); + const { isSignedIn, isOwner } = this.props; + + if(isSignedIn && isOwner) { + this.setState({modal: !this.state.modal}); + } } render() { @@ -391,7 +396,11 @@ class Main extends React.Component { this.setState({ status : response.status, tournament : convertTournament(response.data)}); }) .catch((err) => { - this.setState({ status : err.response.status }); + if(err.response) { + this.setState({ status : err.response.status }); + } else { + this.setState({ status : -1 }); + } }); }