diff --git a/frontend/src/api.js b/frontend/src/api.js index 2177a9c6f..55d6b9240 100644 --- a/frontend/src/api.js +++ b/frontend/src/api.js @@ -161,6 +161,8 @@ class Api { //----TEAM STATS--- + // clean these calls, fix in #368 + // data from scrimmaging static getOwnTeamMuHistory(callback) { return Api.getTeamMuHistory(Cookies.get("team_id"), callback); @@ -259,6 +261,17 @@ class Api { //---TEAM INFO--- + static getTeamProfile(episode, teamId, callback) { + return $.get(`${URL}/api/team/${episode}/t/${teamId}/`) + .done((data, status) => { + callback(data); + }) + .fail((xhr, status, error) => { + console.log("Error in getting user's team profile", xhr, status, error); + callback(null); + }); + } + static getUserTeamProfile(episode, callback) { return $.get(`${URL}/api/team/${episode}/t/me/`) .done((data, status) => { diff --git a/frontend/src/components/rankingTeamList.js b/frontend/src/components/rankingTeamList.js index 090e4c3c9..e25735699 100644 --- a/frontend/src/components/rankingTeamList.js +++ b/frontend/src/components/rankingTeamList.js @@ -7,7 +7,7 @@ import Spinner from "./spinner"; class RankingTeamList extends TeamList { redirectToTeamPage = (team_id) => { - // this.props.history.push(`/rankings/${team_id}`); + this.props.history.push(`/${this.props.episode}/rankings/${team_id}`); }; render() { diff --git a/frontend/src/components/scrimmageRequestor.js b/frontend/src/components/scrimmageRequestor.js index 1bc1bd780..55c62ba2b 100644 --- a/frontend/src/components/scrimmageRequestor.js +++ b/frontend/src/components/scrimmageRequestor.js @@ -94,6 +94,9 @@ class ScrimmageRequestor extends Component {
+ {/* Tracked in #245: + once we support Scrimmages, this RankingTeamList being consturcted should be updated + and include new props */} , - // , + , ( diff --git a/frontend/src/views/rankings.js b/frontend/src/views/rankings.js index dbd1cc0e0..bbce81135 100644 --- a/frontend/src/views/rankings.js +++ b/frontend/src/views/rankings.js @@ -76,6 +76,7 @@ class Rankings extends Component { onPageClick={this.getTeamPage} loading={this.state.loading} history={this.props.history} + episode={this.props.episode} episode_info={this.props.episode_info} />
diff --git a/frontend/src/views/teamInfo.js b/frontend/src/views/teamInfo.js index 3387b474e..9b8b79711 100644 --- a/frontend/src/views/teamInfo.js +++ b/frontend/src/views/teamInfo.js @@ -72,25 +72,39 @@ class WinsCard extends Component { } } +// This is the component in question being rendered class TeamInfo extends Component { - state = { - team: null, - wins: 0, - losses: 0, - }; + constructor(props) { + super(props); + this.state = { + // Note that this prop comes from route-matching. + // (The route to make this is /:episode/rankings/:team_id + // and the :team_id part makes props.match.params.team_id + // whatever that id is) + id: this.props.match.params.team_id, + team: null, + wins: 0, + losses: 0, + }; + } componentDidMount() { - const teamId = this.props.match.params.team_id; //get team info by id - Api.getTeamById(teamId, this.setTeam); + const teamId = this.props.match.params.team_id; + const episode = this.props.match.params.episode; + + Api.getTeamProfile(episode, teamId, this.setTeam); - Api.getOtherTeamWinStats(teamId, (data) => { - this.setState({ wins: data[0], losses: data[1] }); - }); + // Commented out since we don't have scrimmages, records, etc. + // Work on this once we are ready to. + // Track in #368. + // Api.getOtherTeamWinStats(teamId, (data) => { + // this.setState({ wins: data[0], losses: data[1] }); + // }); } - setTeam = (team_data) => { - this.setState({ team: team_data }); + setTeam = (team) => { + this.setState({ team }); }; render() { @@ -102,7 +116,10 @@ class TeamInfo extends Component {
-
+ {/* Commented out since we don't have scrimmages, records, etc. + Work on this once we are ready to. + Do in #368 */} + {/*
@@ -127,7 +144,7 @@ class TeamInfo extends Component {
-
+
*/} );