From b8e151d4bff90e63419ad3e2a6f1e05d392db609 Mon Sep 17 00:00:00 2001 From: Gaurav Arya Date: Tue, 17 Jan 2023 00:33:21 +0800 Subject: [PATCH 1/2] Show list of played tournament matches --- frontend/src/api.js | 30 +++++++++++----- frontend/src/views/scrimmaging.js | 58 +++++++++++++++++++++---------- 2 files changed, 60 insertions(+), 28 deletions(-) diff --git a/frontend/src/api.js b/frontend/src/api.js index 087f0f8cb..677e3be6b 100644 --- a/frontend/src/api.js +++ b/frontend/src/api.js @@ -484,15 +484,6 @@ class Api { }); } - static getAllTeamScrimmages(callback) { - $.get(`${URL}/api/${LEAGUE}/scrimmage/`, (data, success) => { - callback(data); - }); - } - - /* for some reason the data format from getAllTeamScrimmages and getTeamScrimmages - are different; has to do with pagination but not sure how to make the same - */ static getTeamScrimmages(team_id, episode, callback, page) { const query_data = { team_id, @@ -514,6 +505,27 @@ class Api { }); } + static getTeamTournamentMatches(team_id, episode, callback, page) { + const query_data = { + team_id, + page, + }; + return $.get(`${URL}/api/compete/${episode}/match/tournament/`, query_data) + .done((data, status) => { + const pageLimit = Math.ceil(data.count / PAGE_SIZE); + callback(data.results, pageLimit); + }) + .fail((xhr, status, error) => { + console.log( + "Error in getting team's tournament matches", + xhr, + status, + error + ); + callback(null); + }); + } + static getAllMatches(episode, callback, page) { const query_data = { page, diff --git a/frontend/src/views/scrimmaging.js b/frontend/src/views/scrimmaging.js index 41f7b6019..afd67c67f 100644 --- a/frontend/src/views/scrimmaging.js +++ b/frontend/src/views/scrimmaging.js @@ -135,7 +135,7 @@ class ScrimmageRequests extends Component { } } -class ScrimmageHistory extends Component { +class MatchHistory extends Component { state = { scrimPage: 1, pageLimit: 0, @@ -167,7 +167,10 @@ class ScrimmageHistory extends Component { loadPage = (page) => { this.setState({ loading: true, scrimmages: [], scrimPage: page }); - Api.getTeamScrimmages( + const apiFunc = this.props.show_tournament_matches + ? Api.getTeamTournamentMatches + : Api.getTeamScrimmages; + apiFunc( this.props.team.id, this.props.episode, function (scrimmages, pageLimit) { @@ -219,7 +222,10 @@ class ScrimmageHistory extends Component {

- Scrimmage History{" "} + {this.props.show_tournament_matches + ? "Tournament Match" + : "Scrimmage"}{" "} + History{" "}

+
- ); } @@ -372,7 +381,17 @@ class Scrimmaging extends Component { history={this.props.history} team={this.props.team} /> - { + this.history = history; + }} + refresh={this.refresh} + episode={this.props.episode} + episode_info={this.props.episode_info} + team={this.props.team} + show_tournament_matches={false} + /> + { this.history = history; }} @@ -380,6 +399,7 @@ class Scrimmaging extends Component { episode={this.props.episode} episode_info={this.props.episode_info} team={this.props.team} + show_tournament_matches={true} /> From 02238a96f4da242bdaa0cc9d2cae23658031495c Mon Sep 17 00:00:00 2001 From: Jerry Mao Date: Tue, 17 Jan 2023 19:25:55 -0500 Subject: [PATCH 2/2] Show global tournament results --- frontend/src/api.js | 8 ++++++-- frontend/src/index.js | 13 ++++++++++++- frontend/src/views/queue.js | 26 +++++++++++++++++--------- frontend/src/views/tournaments.js | 9 +++++++++ 4 files changed, 44 insertions(+), 12 deletions(-) diff --git a/frontend/src/api.js b/frontend/src/api.js index 677e3be6b..ff6c5995b 100644 --- a/frontend/src/api.js +++ b/frontend/src/api.js @@ -526,11 +526,15 @@ class Api { }); } - static getAllMatches(episode, callback, page) { + static getAllMatches(episode, tournament_id, callback, page) { const query_data = { page, + tournament_id, }; - return $.get(`${URL}/api/compete/${episode}/match/`, query_data) + const endpoint = + `${URL}/api/compete/${episode}/match/` + + (tournament_id !== null ? "tournament/" : ""); + return $.get(endpoint, query_data) .done((data, status) => { const pageLimit = Math.ceil(data.count / PAGE_SIZE); callback(data.results, pageLimit); diff --git a/frontend/src/index.js b/frontend/src/index.js index 1f5684e30..e94372052 100644 --- a/frontend/src/index.js +++ b/frontend/src/index.js @@ -187,6 +187,13 @@ class App extends Component { )} key="tournaments" />, + ( + + )} + key="tournaments" + />, ( @@ -251,7 +258,11 @@ class App extends Component { ( - + )} key="rankings" />, diff --git a/frontend/src/views/queue.js b/frontend/src/views/queue.js index 0a27477f3..5d853bbc8 100644 --- a/frontend/src/views/queue.js +++ b/frontend/src/views/queue.js @@ -24,6 +24,7 @@ class QueueHistory extends Component { pageLimit: 0, matches: [], loading: true, + tournament_id: this.props.match.params.tournament_id ?? null, }; static formatRatingDelta(participation) { @@ -55,6 +56,7 @@ class QueueHistory extends Component { this.setState({ loading: true, matches: [], matchPage: page }); Api.getAllMatches( this.props.episode, + this.state.tournament_id, function (matches, pageLimit) { // This check handles the case where a new page is requested while a // previous page was loading. @@ -98,15 +100,21 @@ class QueueHistory extends Component {

- Recent Queue{" "} - + {this.state.tournament_id === null ? ( + + Recent Queue{" "} + + + ) : ( + Tournament Matches + )}

diff --git a/frontend/src/views/tournaments.js b/frontend/src/views/tournaments.js index 3699b32cd..a5eeaffdc 100644 --- a/frontend/src/views/tournaments.js +++ b/frontend/src/views/tournaments.js @@ -1,4 +1,5 @@ import React, { Component } from "react"; +import { NavLink } from "react-router-dom"; import Api from "../api"; class Tournaments extends Component { componentDidMount() {} @@ -20,6 +21,13 @@ class Tournaments extends Component { ) : ( "" )} + + + View + + {tournament.blurb} ); @@ -52,6 +60,7 @@ class Tournaments extends Component { Tournament Date {this.props.team !== null ? Eligibility : ""} + Results About