Make the tournament page correctly handle status codes from the backend
This commit is contained in:
parent
a8fec087b7
commit
fb93feed45
|
|
@ -26,7 +26,7 @@ export class ErrorPageComponent extends React.Component {
|
|||
}
|
||||
}
|
||||
|
||||
function ErrorPage(props){
|
||||
export function ErrorPage(props){
|
||||
return (
|
||||
<Container className="mb-5">
|
||||
<div className="row mb-5">
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class EditTournamentPage extends React.Component {
|
|||
super(props);
|
||||
|
||||
this.state = {
|
||||
validCode: true
|
||||
validCode: false
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <Container>null</Container>;
|
||||
} else {
|
||||
return <TournamentPage tournament={tournament}/>;
|
||||
}
|
||||
}
|
||||
|
||||
function Stage(props) {
|
||||
return (<div>
|
||||
<Container className='py-5'>
|
||||
|
|
@ -393,14 +384,20 @@ 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;
|
||||
|
||||
const { status, tournament } = this.state;
|
||||
|
||||
if (status == 200) {
|
||||
return (
|
||||
<div>
|
||||
<Head>
|
||||
|
|
@ -408,10 +405,13 @@ class Main extends React.Component {
|
|||
</Head>
|
||||
<TurniereNavigation/>
|
||||
<BigImage text={tournamentName}/>
|
||||
<TournamentContainer data={this.state}/>
|
||||
<TournamentPage tournament={tournament}/>
|
||||
<Footer/>
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
return <ErrorPageComponent code={status}/>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue