diff --git a/js/components/GroupStage.js b/js/components/GroupStage.js
index ffb7857..bd7f4cf 100644
--- a/js/components/GroupStage.js
+++ b/js/components/GroupStage.js
@@ -1,6 +1,8 @@
import {Button, Card, CardBody, Col, Collapse, Row, Table} from 'reactstrap';
import {Match} from './Match';
import React, {Component} from 'react';
+import {getGroup} from '../redux/tournamentApi';
+import {notify} from 'react-notify-toast';
export default class GroupStage extends Component {
constructor(props) {
@@ -33,19 +35,42 @@ function ShowMatchesToggleButton(props) {
);
}
-function Group(props) {
- return (
-
-
- Gruppe {props.group.id + 1}
-
- {props.group.matches.map((match => (
- )))}
-
-
-
-
- );
+class Group extends Component {
+ constructor(props) {
+ super(props);
+ this.state = props.group;
+ this.reload = this.reload.bind(this);
+ this.onReloadSuccess = this.onReloadSuccess.bind(this);
+ this.onReloadError = this.onReloadError.bind(this);
+ }
+
+ reload() {
+ getGroup(this.state.id, this.onReloadSuccess, this.onReloadError);
+ }
+
+ onReloadSuccess(status, updatedGroup) {
+ this.setState(updatedGroup);
+ }
+
+ onReloadError() {
+ notify.show('Die Gruppe konnte nicht aktualisiert werden.', 'warning', 2000);
+ }
+
+ render() {
+ return (
+
+
+ Gruppe {this.state.id + 1}
+
+ {this.state.matches.map((match => (
+ )))}
+
+
+
+
+ );
+ }
}
function GroupScoresTable(props) {
diff --git a/js/components/Match.js b/js/components/Match.js
index 95293d8..e9e01b8 100644
--- a/js/components/Match.js
+++ b/js/components/Match.js
@@ -70,6 +70,7 @@ export class Match extends React.Component {
updatedMatch.team1.score = scoreTeam1;
updatedMatch.team2.score = scoreTeam2;
this.setState({match: updatedMatch});
+ this.props.onChange !== undefined && this.props.onChange();
}
getMatchFinishedMessage() {
diff --git a/js/redux/tournamentApi.js b/js/redux/tournamentApi.js
index 1d7db68..92e7d72 100644
--- a/js/redux/tournamentApi.js
+++ b/js/redux/tournamentApi.js
@@ -9,6 +9,14 @@ export function getTournament(code, successCallback, errorCallback) {
.catch(errorCallback);
}
+export function getGroup(groupId, successCallback, errorCallback) {
+ getRequest(getState(), '/groups/' + groupId)
+ .then(response => {
+ successCallback(response.status, convertGroup(response.data));
+ })
+ .catch(errorCallback);
+}
+
function convertTournament(apiTournament) {
let groupStage = null;
const playoffStages = [];