import React from "react"; import { Button, InputGroup, FormControl } from "react-bootstrap"; 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); this.state = { displayedMatches: [], displayedSports: [], 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"); if (recentMatchesRes.status === 200) { this.setState({ displayedMatches: recentMatchesRes.data.recent }); } } async availableSports() { let availableSportsRes = await apiClient.get("/sport"); if (availableSportsRes.status === 200) { this.setState({ displayedSports: availableSportsRes.data.recent }); } } // 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 (

Available Matches

Available Sports

{/*

Available Equipment

*/}
); } }