diff --git a/js/components/ErrorComponents.js b/js/components/ErrorComponents.js index d33190b..2e84ee9 100644 --- a/js/components/ErrorComponents.js +++ b/js/components/ErrorComponents.js @@ -26,7 +26,7 @@ export class ErrorPageComponent extends React.Component { } } -function ErrorPage(props){ +export function ErrorPage(props){ return (
diff --git a/pages/tournament-edit.js b/pages/tournament-edit.js index 7ddccad..1d147c1 100644 --- a/pages/tournament-edit.js +++ b/pages/tournament-edit.js @@ -34,7 +34,7 @@ class EditTournamentPage extends React.Component { super(props); this.state = { - validCode: true + validCode: false }; } diff --git a/pages/tournament.js b/pages/tournament.js index f155262..779a0ba 100644 --- a/pages/tournament.js +++ b/pages/tournament.js @@ -18,6 +18,7 @@ import { Row, Table } from 'reactstrap'; +import { ErrorPageComponent } from '../js/components/ErrorComponents.js'; import 'bootstrap/dist/css/bootstrap.min.css'; import {BigImage, Footer, TurniereNavigation} from '../js/CommonComponents.js'; import '../static/everypage.css'; @@ -88,16 +89,6 @@ function getLevelName(levelNumber) { } } -function TournamentContainer(props) { - const { tournament } = props.data; - - if (tournament === null) { - return null; - } else { - return ; - } -} - function Stage(props) { return (
@@ -393,25 +384,34 @@ class Main extends React.Component { getRequest(getState(), '/tournaments/' + code) .then(response => { - this.setState({tournament: convertTournament(response.data)}); + this.setState({ status : response.status, tournament : convertTournament(response.data)}); }) - .catch(() => { /* TODO: Show some kind of error or smth */ }); + .catch((err) => { + this.setState({ status : err.response.status }); + }); } render() { const tournamentName = this.state.tournament === null ? 'Turnier' : this.state.tournament.name; - return ( -
- - {tournamentName}: turnie.re - - - - -
-
- ); + + const { status, tournament } = this.state; + + if (status == 200) { + return ( +
+ + {tournamentName}: turnie.re + + + + +
+
+ ); + } else { + return ; + } } }