Add content loading message to TournamentList (both public and private)
This commit is contained in:
parent
5589e8c97e
commit
f8180e2b98
|
|
@ -1,35 +1,51 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {requestTournamentList} from '../api';
|
import {requestTournamentList} from '../api';
|
||||||
|
import {Spinner} from 'react-bootstrap';
|
||||||
|
|
||||||
export default class TournamentList extends React.Component {
|
export default class TournamentList extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
tournaments: []
|
tournaments: [],
|
||||||
|
loaded: false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
requestTournamentList(this.props.type, tournaments => {
|
requestTournamentList(this.props.type, tournaments => {
|
||||||
this.setState({
|
this.setState({
|
||||||
tournaments: tournaments
|
tournaments: tournaments,
|
||||||
|
loaded: true
|
||||||
});
|
});
|
||||||
}, () => {});
|
}, () => {
|
||||||
|
this.setState({loaded: true});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (this.state.tournaments.length === 0) {
|
if (!this.state.loaded) {
|
||||||
return <p className="text-center border-light font-italic text-secondary border-top border-bottom p-1">keine
|
return (<EmptyList>
|
||||||
Turniere vorhanden</p>;
|
<Spinner animation='border' role='status' size='sm'/>
|
||||||
} else {
|
<span className='ml-3'>lade Turnier-Liste</span>
|
||||||
return this.state.tournaments.map(item => (
|
</EmptyList>);
|
||||||
// The code should be item.code but the api just supports it this way by now
|
|
||||||
<TournamentListEntry name={item.name} code={item.id} key={item.id}/>
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.state.tournaments.length === 0) {
|
||||||
|
return <EmptyList>keine Turniere vorhanden</EmptyList>;
|
||||||
|
}
|
||||||
|
return this.state.tournaments.map(item => (
|
||||||
|
// The code should be item.code but the api just supports it this way by now
|
||||||
|
<TournamentListEntry name={item.name} code={item.id} key={item.id}/>
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function EmptyList(props) {
|
||||||
|
return (<p className="text-center border-light font-italic text-secondary border-top border-bottom p-1">
|
||||||
|
{props.children}
|
||||||
|
</p>);
|
||||||
|
}
|
||||||
|
|
||||||
function TournamentListEntry(props) {
|
function TournamentListEntry(props) {
|
||||||
return (
|
return (
|
||||||
<a className="w-100 d-inline-block mt-2 text-left btn btn-outline-primary" href={'/t/' + props.code}>
|
<a className="w-100 d-inline-block mt-2 text-left btn btn-outline-primary" href={'/t/' + props.code}>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue