Merge pull request #10 from turniere/ticket/TURNIERE-131
Hide Match update Dialog when unauthorized
This commit is contained in:
commit
9eabd42bfe
|
|
@ -35,16 +35,17 @@ import 'bootstrap/dist/css/bootstrap.min.css';
|
||||||
import '../static/everypage.css';
|
import '../static/everypage.css';
|
||||||
import '../static/css/tournament.css';
|
import '../static/css/tournament.css';
|
||||||
|
|
||||||
class TournamentPage extends React.Component {
|
class PrivateTournamentPage extends React.Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { id, description, isPublic, code, ownerUsername, playoffStages } = this.props.tournament;
|
const { id, description, isPublic, code, ownerUsername, playoffStages } = this.props.tournament;
|
||||||
|
const { isSignedIn, username } = this.props;
|
||||||
|
|
||||||
// TODO: Change href-prop of the anchor tag to contain the tournament code
|
// TODO: Change href-prop of the anchor tag to contain the tournament code
|
||||||
return (
|
return (
|
||||||
<div className='pb-5'>
|
<div className='pb-5'>
|
||||||
<Container>
|
<Container>
|
||||||
<EditButton id={id} ownerName={ownerUsername}/>
|
<EditButton id={id} ownerName={ownerUsername} isSignedIn={isSignedIn} username={username}/>
|
||||||
<p>{description}</p>
|
<p>{description}</p>
|
||||||
<ListGroup>
|
<ListGroup>
|
||||||
<ListGroupItem>
|
<ListGroupItem>
|
||||||
|
|
@ -56,14 +57,23 @@ class TournamentPage extends React.Component {
|
||||||
</Container>
|
</Container>
|
||||||
<div className='stages pt-5'>
|
<div className='stages pt-5'>
|
||||||
{playoffStages.map(stage =>
|
{playoffStages.map(stage =>
|
||||||
<Stage level={getLevelName(stage.level)} matches={stage.matches} key={stage.level}/>)}
|
<Stage isSignedIn={isSignedIn} isOwner={username == ownerUsername} level={getLevelName(stage.level)} matches={stage.matches} key={stage.level}/>)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function PrivateEditButton(props) {
|
function mapStateToTournamentPageProperties(state) {
|
||||||
|
const { isSignedIn, username } = state.userinfo;
|
||||||
|
return { isSignedIn, username };
|
||||||
|
}
|
||||||
|
|
||||||
|
const TournamentPage = connect(
|
||||||
|
mapStateToTournamentPageProperties
|
||||||
|
)(PrivateTournamentPage);
|
||||||
|
|
||||||
|
function EditButton(props) {
|
||||||
const { id, ownerName, isSignedIn, username } = props;
|
const { id, ownerName, isSignedIn, username } = props;
|
||||||
|
|
||||||
if(isSignedIn && ownerName === username) {
|
if(isSignedIn && ownerName === username) {
|
||||||
|
|
@ -75,15 +85,6 @@ function PrivateEditButton(props) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapStateToEditButtonProperties(state) {
|
|
||||||
const { isSignedIn, username } = state.userinfo;
|
|
||||||
return { isSignedIn, username };
|
|
||||||
}
|
|
||||||
|
|
||||||
const EditButton = connect(
|
|
||||||
mapStateToEditButtonProperties
|
|
||||||
)(PrivateEditButton);
|
|
||||||
|
|
||||||
function getLevelName(levelNumber) {
|
function getLevelName(levelNumber) {
|
||||||
const names = ['Finale', 'Halbfinale', 'Viertelfinale', 'Achtelfinale'];
|
const names = ['Finale', 'Halbfinale', 'Viertelfinale', 'Achtelfinale'];
|
||||||
if(levelNumber < names.length){
|
if(levelNumber < names.length){
|
||||||
|
|
@ -116,8 +117,12 @@ class Match extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleModal() {
|
toggleModal() {
|
||||||
|
const { isSignedIn, isOwner } = this.props;
|
||||||
|
|
||||||
|
if(isSignedIn && isOwner) {
|
||||||
this.setState({modal: !this.state.modal});
|
this.setState({modal: !this.state.modal});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let cardClass, smallMessage, borderClass;
|
let cardClass, smallMessage, borderClass;
|
||||||
|
|
@ -391,7 +396,11 @@ class Main extends React.Component {
|
||||||
this.setState({ status : response.status, tournament : convertTournament(response.data)});
|
this.setState({ status : response.status, tournament : convertTournament(response.data)});
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
if(err.response) {
|
||||||
this.setState({ status : err.response.status });
|
this.setState({ status : err.response.status });
|
||||||
|
} else {
|
||||||
|
this.setState({ status : -1 });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue