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 (
|
return (
|
||||||
<Container className="mb-5">
|
<Container className="mb-5">
|
||||||
<div className="row mb-5">
|
<div className="row mb-5">
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ class EditTournamentPage extends React.Component {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
validCode: true
|
validCode: false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import {
|
||||||
Row,
|
Row,
|
||||||
Table
|
Table
|
||||||
} from 'reactstrap';
|
} from 'reactstrap';
|
||||||
|
import { ErrorPageComponent } from '../js/components/ErrorComponents.js';
|
||||||
import 'bootstrap/dist/css/bootstrap.min.css';
|
import 'bootstrap/dist/css/bootstrap.min.css';
|
||||||
import {BigImage, Footer, TurniereNavigation} from '../js/CommonComponents.js';
|
import {BigImage, Footer, TurniereNavigation} from '../js/CommonComponents.js';
|
||||||
import '../static/everypage.css';
|
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) {
|
function Stage(props) {
|
||||||
return (<div>
|
return (<div>
|
||||||
<Container className='py-5'>
|
<Container className='py-5'>
|
||||||
|
|
@ -393,14 +384,20 @@ class Main extends React.Component {
|
||||||
|
|
||||||
getRequest(getState(), '/tournaments/' + code)
|
getRequest(getState(), '/tournaments/' + code)
|
||||||
.then(response => {
|
.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() {
|
render() {
|
||||||
const tournamentName = this.state.tournament === null ? 'Turnier' : this.state.tournament.name;
|
const tournamentName = this.state.tournament === null ? 'Turnier' : this.state.tournament.name;
|
||||||
|
|
||||||
|
const { status, tournament } = this.state;
|
||||||
|
|
||||||
|
if (status == 200) {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Head>
|
<Head>
|
||||||
|
|
@ -408,10 +405,13 @@ class Main extends React.Component {
|
||||||
</Head>
|
</Head>
|
||||||
<TurniereNavigation/>
|
<TurniereNavigation/>
|
||||||
<BigImage text={tournamentName}/>
|
<BigImage text={tournamentName}/>
|
||||||
<TournamentContainer data={this.state}/>
|
<TournamentPage tournament={tournament}/>
|
||||||
<Footer/>
|
<Footer/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
return <ErrorPageComponent code={status}/>;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue