Resolve conflicts and fix style issues
This commit is contained in:
parent
e77e3f6dc8
commit
498e0353c1
|
|
@ -1,5 +1,5 @@
|
|||
import Head from 'next/head'
|
||||
import React from 'react'
|
||||
import Head from 'next/head';
|
||||
import React from 'react';
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
|
|
@ -19,16 +19,17 @@ import {
|
|||
Table
|
||||
} from 'reactstrap';
|
||||
import 'bootstrap/dist/css/bootstrap.min.css';
|
||||
import {BigImage, Footer, TurniereNavigation} from '../js/CommonComponents.js'
|
||||
import '../static/everypage.css'
|
||||
import '../static/css/tournament.css'
|
||||
import {getRequest} from '../js/api';
|
||||
import {BigImage, Footer, TurniereNavigation} from '../js/CommonComponents.js';
|
||||
import '../static/everypage.css';
|
||||
import '../static/css/tournament.css';
|
||||
import { getRequest, getState } from '../js/api';
|
||||
|
||||
function Tournament(props) {
|
||||
// TODO: Change href-prop of the anchor tag to contain the tournament code
|
||||
return (
|
||||
<div className='pb-5'>
|
||||
<Container>
|
||||
<a href='edit' className='btn btn-outline-secondary'>Turnier bearbeiten</a>
|
||||
<a href={'/t/' + props.tournament.id + '/edit'} className='btn btn-outline-secondary'>Turnier bearbeiten</a>
|
||||
<p>{props.tournament.description}</p>
|
||||
<ListGroup>
|
||||
<ListGroupItem>
|
||||
|
|
@ -49,17 +50,17 @@ function Tournament(props) {
|
|||
function getLevelName(levelNumber) {
|
||||
const names = ['Finale', 'Halbfinale', 'Viertelfinale', 'Achtelfinale'];
|
||||
if(levelNumber < names.length){
|
||||
return names[levelNumber]
|
||||
return names[levelNumber];
|
||||
}else {
|
||||
return Math.pow(2, levelNumber) + 'tel-Finale'
|
||||
return Math.pow(2, levelNumber) + 'tel-Finale';
|
||||
}
|
||||
}
|
||||
|
||||
function TournamentContainer(props) {
|
||||
if (props.data === null) {
|
||||
return <Container>null</Container>
|
||||
return <Container>null</Container>;
|
||||
} else {
|
||||
return <Tournament tournament={props.data.tournament}/>
|
||||
return <Tournament tournament={props.data.tournament}/>;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -86,11 +87,11 @@ class Match extends React.Component {
|
|||
}
|
||||
|
||||
toggleModal() {
|
||||
this.setState({modal: !this.state.modal})
|
||||
this.setState({modal: !this.state.modal});
|
||||
}
|
||||
|
||||
render() {
|
||||
let cardClass, team1Class, team2Class, smallMessage, borderClass;
|
||||
let cardClass, smallMessage, borderClass;
|
||||
//possible states: single_team not_ready not_started in_progress team1_won team2_won undecided
|
||||
switch (this.props.match.state) {
|
||||
case 'in_progress':
|
||||
|
|
@ -99,21 +100,16 @@ class Match extends React.Component {
|
|||
smallMessage = 'Spiel läuft';
|
||||
break;
|
||||
case 'team1_won':
|
||||
team1Class = 'font-weight-bold';
|
||||
team2Class = 'lost-team';
|
||||
cardClass = 'table-success';
|
||||
borderClass = 'border-success';
|
||||
smallMessage = 'Gewinner: ' + this.props.match.team1;
|
||||
break;
|
||||
case 'team2_won':
|
||||
team1Class = 'lost-team';
|
||||
team2Class = 'font-weight-bold';
|
||||
cardClass = 'table-success';
|
||||
borderClass = 'border-success';
|
||||
smallMessage = 'Gewinner: ' + this.props.match.team2;
|
||||
break;
|
||||
case 'single_team':
|
||||
team2Class = 'text-muted';
|
||||
cardClass = 'table-success';
|
||||
borderClass = 'border-success';
|
||||
smallMessage = 'kein Gegner, Team kommt weiter';
|
||||
|
|
@ -224,8 +220,8 @@ function MatchTable(props) {
|
|||
</tr>
|
||||
</tbody>
|
||||
</Table>
|
||||
)
|
||||
}else{
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<Table className='mb-0'>
|
||||
<tbody>
|
||||
|
|
@ -239,7 +235,7 @@ function MatchTable(props) {
|
|||
</tr>
|
||||
</tbody>
|
||||
</Table>
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -261,7 +257,7 @@ function EditableMatchTable(props) {
|
|||
</tr>
|
||||
</tbody>
|
||||
</Table>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
class ScoreInput extends React.Component {
|
||||
|
|
@ -307,7 +303,7 @@ function convertTournament(apiTournament) {
|
|||
id: stage.id,
|
||||
level: stage.level,
|
||||
matches: stage.matches.map(match => convertMatch(match))
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
return {
|
||||
|
|
@ -328,7 +324,7 @@ function convertGroup(apiGroup) {
|
|||
number: apiGroup.number,
|
||||
scores: apiGroup.group_scores,
|
||||
matches: apiGroup.matches.map(match => convertMatch(match))
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function convertMatch(apiMatch) {
|
||||
|
|
@ -339,18 +335,18 @@ function convertMatch(apiMatch) {
|
|||
team2: apiMatch.match_scores[1].team.name,
|
||||
scoreTeam1: apiMatch.match_scores[0].points,
|
||||
scoreTeam2: apiMatch.match_scores[1].points
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
class Main extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
const code = this.props.query.code;
|
||||
getRequest('/tournaments/' + code, {})
|
||||
getRequest(getState(), '/tournaments/' + code)
|
||||
.then(response => {
|
||||
this.setState({tournament: convertTournament(response.data)});
|
||||
})
|
||||
.catch(error => console.log(error));
|
||||
.catch(() => { /* TODO: Show some kind of error or smth */ });
|
||||
}
|
||||
|
||||
static async getInitialProps({query}) {
|
||||
|
|
@ -373,4 +369,4 @@ class Main extends React.Component {
|
|||
}
|
||||
}
|
||||
|
||||
export default Main
|
||||
export default Main;
|
||||
|
|
|
|||
Loading…
Reference in New Issue