Skip to content

Commit

Permalink
Schedule overview tab now grabs the appropriate set of matches based …
Browse files Browse the repository at this point in the history
…on tournament id.
  • Loading branch information
kyle-flynn committed Aug 30, 2019
1 parent e9e7752 commit 8ff0cd6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
2 changes: 1 addition & 1 deletion ems-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"main": "build/electron.js",
"dependencies": {
"@the-orange-alliance/lib-ems": "^0.7.8",
"@the-orange-alliance/lib-ems": "^0.7.9",
"axios": "^0.19.0",
"dotenv": "^8.0.0",
"local-ipv4-address": "0.0.2",
Expand Down
21 changes: 16 additions & 5 deletions ems-core/src/components/SetupScheduleOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import DialogManager from "../managers/DialogManager";
import {EMSProvider, HttpError, ScheduleItem, TournamentType} from "@the-orange-alliance/lib-ems";

interface IProps {
eventKey?: string;
type: TournamentType;
tournamentId?: number;
}
Expand All @@ -22,11 +23,21 @@ class SetupScheduleOverview extends React.Component<IProps, IState> {
}

public componentDidMount() {
EMSProvider.getScheduleItems(this.props.type).then((scheduleItems: ScheduleItem[]) => {
this.setState({scheduleItems});
}).catch((err: HttpError) => {
DialogManager.showErrorBox(err);
});
const {eventKey, tournamentId, type} = this.props;
if (tournamentId) {
const matchType: string = type.substring(0, 1).toUpperCase();
EMSProvider.getPlayoffsScheduleItems(type, `${eventKey}-${matchType}`, tournamentId).then((scheduleItems: ScheduleItem[]) => {
this.setState({scheduleItems});
}).catch((err: HttpError) => {
DialogManager.showErrorBox(err);
});
} else {
EMSProvider.getScheduleItems(this.props.type).then((scheduleItems: ScheduleItem[]) => {
this.setState({scheduleItems});
}).catch((err: HttpError) => {
DialogManager.showErrorBox(err);
});
}
}

public render() {
Expand Down
14 changes: 8 additions & 6 deletions ems-core/src/components/TournamentScheduleOverview.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import * as React from "react";
import {EventConfiguration, TournamentRound} from "@the-orange-alliance/lib-ems";
import {Event, EventConfiguration, TournamentRound} from "@the-orange-alliance/lib-ems";
import {IApplicationState} from "../stores";
import {connect} from "react-redux";
import {Tab} from "semantic-ui-react";
import SetupScheduleOverview from "./SetupScheduleOverview";

interface IProps {
eventConfig?: EventConfiguration
event?: Event;
eventConfig?: EventConfiguration;
}

class TournamentScheduleOverview extends React.Component<IProps> {
Expand All @@ -15,7 +16,7 @@ class TournamentScheduleOverview extends React.Component<IProps> {
}

public render() {
const {eventConfig} = this.props;
const {event, eventConfig} = this.props;
let activeTournament: TournamentRound;

if (Array.isArray(eventConfig.tournament)) {
Expand All @@ -42,13 +43,13 @@ class TournamentScheduleOverview extends React.Component<IProps> {
} else {
switch (activeTournament.type) {
case "rr":
view = <SetupScheduleOverview type={"Round Robin"}/>;
view = <SetupScheduleOverview eventKey={event.eventKey} tournamentId={activeTournament.id} type={"Round Robin"}/>;
break;
case "elims":
view = <SetupScheduleOverview type={"Eliminations"}/>;
view = <SetupScheduleOverview eventKey={event.eventKey} tournamentId={activeTournament.id} type={"Eliminations"}/>;
break;
case "ranking":
view = <SetupScheduleOverview type={"Ranking"}/>;
view = <SetupScheduleOverview eventKey={event.eventKey} tournamentId={activeTournament.id} type={"Ranking"}/>;
break;
}
}
Expand All @@ -59,6 +60,7 @@ class TournamentScheduleOverview extends React.Component<IProps> {

export function mapStateToProps({configState}: IApplicationState) {
return {
event: configState.event,
eventConfig: configState.eventConfiguration
};
}
Expand Down

0 comments on commit 8ff0cd6

Please sign in to comment.