diff --git a/sports-matcher/client/src/components/SportInfoCardDisplay.js b/sports-matcher/client/src/components/SportInfoCardDisplay.js index 649572f..c50e71d 100644 --- a/sports-matcher/client/src/components/SportInfoCardDisplay.js +++ b/sports-matcher/client/src/components/SportInfoCardDisplay.js @@ -8,7 +8,7 @@ export default class SportInfoCardDisplay extends React.Component { } render() { let sports = null; - if(this.props.recommendedsports && this.props.recommendedsports.length > 0) { + if (this.props.recommendedsports.length > 0) { sports = this.props.recommendedsports.map((sport) => ); } return ( diff --git a/sports-matcher/client/src/pages/Dashboard.js b/sports-matcher/client/src/pages/Dashboard.js index f3689ca..e400a1b 100644 --- a/sports-matcher/client/src/pages/Dashboard.js +++ b/sports-matcher/client/src/pages/Dashboard.js @@ -4,7 +4,6 @@ import "../styles/Dashboard.css"; import { apiClient } from "../utils/httpClients.js"; import MatchInfoCardDisplay from "../components/MatchInfoCardDisplay"; import SportInfoCardDisplay from "../components/SportInfoCardDisplay"; -// import { needUser } from "../utils/routing.js"; export default class Dashboard extends React.Component { constructor(props) { super(props); @@ -14,16 +13,11 @@ export default class Dashboard extends React.Component { displayedEquipment: [], user: null }; - // this.getFirstName(); } - // async componentDidMount() { - // this.setState({ user: await needUser() }); // needUser says this page needs a user, and therefore, if there isn't a user, get them to login first. It returns the authenticated user. - // this.setState({ displayedMatches: await this.latestMatches() }); - // } + async componentDidMount() { await this.latestMatches(); await this.availableSports(); - // await this.availableEquipment(); } async latestMatches() { let recentMatchesRes = await apiClient.get("/match/recent/15"); @@ -35,23 +29,10 @@ export default class Dashboard extends React.Component { async availableSports() { let availableSportsRes = await apiClient.get("/sport"); if (availableSportsRes.status === 200) { - this.setState({ displayedSports: availableSportsRes.data.recent }); + this.setState({ displayedSports: availableSportsRes.data }); } } - // async availableEquipment() { - // let availableEquipmentRes = await apiClient.get("/rentals"); - // if (availableEquipmentRes.status === 200) { - // this.setState({ displayedEquipment: availableEquipmentRes.data.recent }); - // } - // } - - // async getFirstName() { - // // let result = await apiClient.post("/user/login", {"email": "johndoe@gmail.com", "password": "csc309h1"}).then(apiClient.get("/user")); - // let user = await apiClient.get("/user"); - // let tags = document.getElementsByTagName("h1"); - // tags[0].innerHTML = user.firstName; - // } render() { return ( @@ -74,10 +55,7 @@ export default class Dashboard extends React.Component { Available Sports - {/* - Available Equipment - - */} + );