Skip to content
This repository was archived by the owner on May 17, 2022. It is now read-only.

Commit

Permalink
Add content loading message to TournamentList (both public and private)
Browse files Browse the repository at this point in the history
  • Loading branch information
betanummeric committed Jun 20, 2019
1 parent 5589e8c commit f8180e2
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions js/components/TournamentList.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,51 @@
import React from 'react';
import {requestTournamentList} from '../api';
import {Spinner} from 'react-bootstrap';

export default class TournamentList extends React.Component {
constructor(props) {
super(props);
this.state = {
tournaments: []
tournaments: [],
loaded: false
};
}

componentDidMount() {
requestTournamentList(this.props.type, tournaments => {
this.setState({
tournaments: tournaments
tournaments: tournaments,
loaded: true
});
}, () => {});
}, () => {
this.setState({loaded: true});
});
}

render() {
if (!this.state.loaded) {
return (<EmptyList>
<Spinner animation='border' role='status' size='sm'/>
<span className='ml-3'>lade Turnier-Liste</span>
</EmptyList>);
}

if (this.state.tournaments.length === 0) {
return <p className="text-center border-light font-italic text-secondary border-top border-bottom p-1">keine
Turniere vorhanden</p>;
} else {
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}/>
));
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) {
return (
<a className="w-100 d-inline-block mt-2 text-left btn btn-outline-primary" href={'/t/' + props.code}>
Expand Down

0 comments on commit f8180e2

Please sign in to comment.