Merge branch 'restructure' into login-page

This commit is contained in:
Harrison Deng 2022-04-05 14:22:28 -05:00
commit e4db4ab403
3 changed files with 83 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import Navbar from "react-bootstrap/Navbar";
import { Container, Nav, NavbarBrand } from "react-bootstrap";
import NavbarToggle from "react-bootstrap/esm/NavbarToggle";
import NavbarCollapse from "react-bootstrap/esm/NavbarCollapse";
import Dashboard from "./pages/Dashboard";
export default class Layout extends React.Component {
render() {
return (
@ -29,6 +30,7 @@ export default class Layout extends React.Component {
<main>
<Routes>
<Route path="/" element={<Welcome></Welcome>} />
<Route path="/Dashboard" element={<Dashboard></Dashboard>} />
</Routes>
</main>
<footer>

View File

@ -0,0 +1,76 @@
import React from "react";
import { Button, InputGroup, FormControl } from "react-bootstrap";
import "../styles/Dashboard.css";
import { apiClient } from "../utils/httpClients";
import MatchInfoCardDisplay from "../components/MatchInfoCardDisplay";
export default class Dashboard extends React.Component{
constructor(props) {
super(props);
this.state = {
displayedMatches: [],
displayedSports: [],
displayedEquipment: []
};
this.getFirstName();
}
async componentDidMount() {
await this.latestMatches();
}
async latestMatches() {
let recentMatchesRes = await apiClient.get("/match/recent/15");
if (recentMatchesRes.status === 200) {
this.setState({ displayedMatches: recentMatchesRes.data.recent });
}
}
async availableMatches() {
let availableMatchesRes = await apiClient.get("/sports");
if (availableMatchesRes.status === 200) {
this.setState({ displayedSports: availableMatchesRes.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(
<React.Fragment>
<h1></h1>
<InputGroup className="w-50">
<FormControl
placeholder="Search for Matches"
aria-label="Search Bar"
aria-describedby="basic-addon2"
/>
<Button variant="outline-secondary" id="button-addon2">
Search
</Button>
</InputGroup>
<div className="p-4">
<h2>Available Matches</h2>
<MatchInfoCardDisplay recommendedmatches={this.state.displayedMatches} />
</div>
<div className="p-4">
<h2>Available Sports</h2>
<MatchInfoCardDisplay recommendedmatches={this.state.displayedSports} />
</div>
<div className="p-4">
<h2>Available Equipment</h2>
<MatchInfoCardDisplay recommendedmatches={this.state.displayedEquipment} />
</div>
</React.Fragment>
);
}
}

View File

@ -0,0 +1,5 @@
.w-50{
margin-top: 5%;
margin-left: 25%;
margin-right: 25%;
}