diff --git a/js/components/EditableMatchTable.js b/js/components/EditableMatchTable.js
new file mode 100644
index 0000000..c19f883
--- /dev/null
+++ b/js/components/EditableMatchTable.js
@@ -0,0 +1,54 @@
+import React from 'react';
+import {Button, Input, InputGroup, InputGroupAddon, Table} from 'reactstrap';
+
+export function EditableMatchTable(props) {
+ return (
+
+
+ |
+
+ |
+ {props.match.team1.name} |
+
+
+ |
+
+ |
+ {props.match.team2.name} |
+
+
+
);
+}
+
+class ScoreInput extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {score: this.props.score};
+ this.updateScore = this.updateScore.bind(this);
+ this.increaseScore = this.increaseScore.bind(this);
+ this.decreaseScore = this.decreaseScore.bind(this);
+ }
+
+ updateScore(event) {
+ this.setState({score: event.target.value});
+ }
+
+ increaseScore() {
+ this.setState({score: Number(this.state.score) + 1});
+ }
+
+ decreaseScore() {
+ this.setState({score: Number(this.state.score) - 1});
+ }
+
+ render() {
+ return (
+
+
+
+ );
+ }
+}
diff --git a/js/components/Match.js b/js/components/Match.js
index 55a4e9a..f12481e 100644
--- a/js/components/Match.js
+++ b/js/components/Match.js
@@ -1,19 +1,9 @@
-import {
- Button,
- Card,
- CardBody,
- Input,
- InputGroup,
- InputGroupAddon,
- Modal,
- ModalBody,
- ModalFooter,
- ModalHeader,
- Table
-} from 'reactstrap';
+import {Card, CardBody} from 'reactstrap';
import React from 'react';
import {endMatch, startMatch} from '../api';
import {notify} from 'react-notify-toast';
+import {MatchModal} from './MatchModal';
+import {MatchTable} from './MatchTable';
export class Match extends React.Component {
@@ -129,145 +119,3 @@ export class Match extends React.Component {
}
}
-function MatchModal(props) {
- let title;
- let actionButton = '';
- // possible states: single_team not_ready not_started in_progress finished
- switch (props.match.state) {
- case 'in_progress':
- title = 'Spiel läuft';
- actionButton = ;
- break;
- case 'finished':
- title = 'Spiel beendet';
- break;
- case 'single_team':
- title = 'kein Gegner, Team kommt weiter';
- break;
- case 'not_ready':
- title = 'Spiel kann noch nicht gestartet werden';
- break;
- case 'not_started':
- title = 'Spiel kann gestartet werden';
- actionButton = ;
- break;
- }
- return (
- {title}
-
- {props.match.state === 'in_progress' ? :
- }
-
-
- {actionButton}
-
-
- );
-}
-
-function MatchTable(props) {
- let team1Class;
- let team2Class;
- // possible states: single_team not_ready not_started in_progress finished
- switch (props.matchState) {
- case 'in_progress':
- break;
- case 'finished':
- if (props.match.winnerTeamId === undefined) {
- break;
- }
- if (props.winnerTeamId === props.match.team1.id) {
- team1Class = 'font-weight-bold';
- team2Class = 'lost-team';
- }
- if (props.winnerTeamId === props.match.team2.id) {
- team1Class = 'lost-team';
- team2Class = 'font-weight-bold';
- }
- break;
- case 'single_team':
- team2Class = 'text-muted';
- break;
- case 'not_ready':
- break;
- case 'not_started':
- break;
- }
- if (props.match.state === 'single_team') {
- return (
-
-
- | {props.match.team1.name} |
-
-
- | kein Gegner |
-
-
-
);
- } else {
- return (
-
-
- | {props.match.team1.score} |
- {props.match.team1.name} |
-
-
- | {props.match.team2.score} |
- {props.match.team2.name} |
-
-
-
);
- }
-}
-
-function EditableMatchTable(props) {
- return (
-
-
- |
-
- |
- {props.match.team1.name} |
-
-
- |
-
- |
- {props.match.team2.name} |
-
-
-
);
-}
-
-class ScoreInput extends React.Component {
- constructor(props) {
- super(props);
- this.state = {score: this.props.score};
- this.updateScore = this.updateScore.bind(this);
- this.increaseScore = this.increaseScore.bind(this);
- this.decreaseScore = this.decreaseScore.bind(this);
- }
-
- updateScore(event) {
- this.setState({score: event.target.value});
- }
-
- increaseScore() {
- this.setState({score: Number(this.state.score) + 1});
- }
-
- decreaseScore() {
- this.setState({score: Number(this.state.score) - 1});
- }
-
- render() {
- return (
-
-
-
- );
- }
-}
diff --git a/js/components/MatchModal.js b/js/components/MatchModal.js
new file mode 100644
index 0000000..e2eef0c
--- /dev/null
+++ b/js/components/MatchModal.js
@@ -0,0 +1,40 @@
+import {Button, Modal, ModalBody, ModalFooter, ModalHeader} from 'reactstrap';
+import React from 'react';
+import {EditableMatchTable} from './EditableMatchTable';
+import {MatchTable} from './MatchTable';
+
+export function MatchModal(props) {
+ let title;
+ let actionButton = '';
+ // possible states: single_team not_ready not_started in_progress finished
+ switch (props.match.state) {
+ case 'in_progress':
+ title = 'Spiel läuft';
+ actionButton = ;
+ break;
+ case 'finished':
+ title = 'Spiel beendet';
+ break;
+ case 'single_team':
+ title = 'kein Gegner, Team kommt weiter';
+ break;
+ case 'not_ready':
+ title = 'Spiel kann noch nicht gestartet werden';
+ break;
+ case 'not_started':
+ title = 'Spiel kann gestartet werden';
+ actionButton = ;
+ break;
+ }
+ return (
+ {title}
+
+ {props.match.state === 'in_progress' ? :
+ }
+
+
+ {actionButton}
+
+
+ );
+}
diff --git a/js/components/MatchTable.js b/js/components/MatchTable.js
new file mode 100644
index 0000000..fda69d9
--- /dev/null
+++ b/js/components/MatchTable.js
@@ -0,0 +1,57 @@
+import {Table} from 'reactstrap';
+import React from 'react';
+
+export function MatchTable(props) {
+ let team1Class;
+ let team2Class;
+ // possible states: single_team not_ready not_started in_progress finished
+ switch (props.matchState) {
+ case 'in_progress':
+ break;
+ case 'finished':
+ if (props.match.winnerTeamId === undefined) {
+ break;
+ }
+ if (props.winnerTeamId === props.match.team1.id) {
+ team1Class = 'font-weight-bold';
+ team2Class = 'lost-team';
+ }
+ if (props.winnerTeamId === props.match.team2.id) {
+ team1Class = 'lost-team';
+ team2Class = 'font-weight-bold';
+ }
+ break;
+ case 'single_team':
+ team2Class = 'text-muted';
+ break;
+ case 'not_ready':
+ break;
+ case 'not_started':
+ break;
+ }
+ if (props.match.state === 'single_team') {
+ return (
+
+
+ | {props.match.team1.name} |
+
+
+ | kein Gegner |
+
+
+
);
+ } else {
+ return (
+
+
+ | {props.match.team1.score} |
+ {props.match.team1.name} |
+
+
+ | {props.match.team2.score} |
+ {props.match.team2.name} |
+
+
+
);
+ }
+}