Fixed sport display.
This commit is contained in:
		@@ -8,7 +8,7 @@ export default class SportInfoCardDisplay extends React.Component {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    render() {
 | 
					    render() {
 | 
				
			||||||
        let sports = null;
 | 
					        let sports = null;
 | 
				
			||||||
        if(this.props.recommendedsports && this.props.recommendedsports.length > 0) {
 | 
					        if (this.props.recommendedsports.length > 0) {
 | 
				
			||||||
            sports = this.props.recommendedsports.map((sport) => <SportInfoCard key={sport._id} sport={sport}></SportInfoCard>);
 | 
					            sports = this.props.recommendedsports.map((sport) => <SportInfoCard key={sport._id} sport={sport}></SportInfoCard>);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return (
 | 
					        return (
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,7 +4,6 @@ import "../styles/Dashboard.css";
 | 
				
			|||||||
import { apiClient } from "../utils/httpClients.js";
 | 
					import { apiClient } from "../utils/httpClients.js";
 | 
				
			||||||
import MatchInfoCardDisplay from "../components/MatchInfoCardDisplay";
 | 
					import MatchInfoCardDisplay from "../components/MatchInfoCardDisplay";
 | 
				
			||||||
import SportInfoCardDisplay from "../components/SportInfoCardDisplay";
 | 
					import SportInfoCardDisplay from "../components/SportInfoCardDisplay";
 | 
				
			||||||
// import { needUser } from "../utils/routing.js";
 | 
					 | 
				
			||||||
export default class Dashboard extends React.Component {
 | 
					export default class Dashboard extends React.Component {
 | 
				
			||||||
    constructor(props) {
 | 
					    constructor(props) {
 | 
				
			||||||
        super(props);
 | 
					        super(props);
 | 
				
			||||||
@@ -14,16 +13,11 @@ export default class Dashboard extends React.Component {
 | 
				
			|||||||
            displayedEquipment: [],
 | 
					            displayedEquipment: [],
 | 
				
			||||||
            user: null
 | 
					            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() {
 | 
					    async componentDidMount() {
 | 
				
			||||||
        await this.latestMatches();
 | 
					        await this.latestMatches();
 | 
				
			||||||
        await this.availableSports();
 | 
					        await this.availableSports();
 | 
				
			||||||
        // await this.availableEquipment();
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    async latestMatches() {
 | 
					    async latestMatches() {
 | 
				
			||||||
        let recentMatchesRes = await apiClient.get("/match/recent/15");
 | 
					        let recentMatchesRes = await apiClient.get("/match/recent/15");
 | 
				
			||||||
@@ -35,23 +29,10 @@ export default class Dashboard extends React.Component {
 | 
				
			|||||||
    async availableSports() {
 | 
					    async availableSports() {
 | 
				
			||||||
        let availableSportsRes = await apiClient.get("/sport");
 | 
					        let availableSportsRes = await apiClient.get("/sport");
 | 
				
			||||||
        if (availableSportsRes.status === 200) {
 | 
					        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() {
 | 
					    render() {
 | 
				
			||||||
        return (
 | 
					        return (
 | 
				
			||||||
            <React.Fragment>
 | 
					            <React.Fragment>
 | 
				
			||||||
@@ -74,10 +55,7 @@ export default class Dashboard extends React.Component {
 | 
				
			|||||||
                    <h2>Available Sports</h2>
 | 
					                    <h2>Available Sports</h2>
 | 
				
			||||||
                    <SportInfoCardDisplay recommendedsports={this.state.displayedSports} />
 | 
					                    <SportInfoCardDisplay recommendedsports={this.state.displayedSports} />
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
                {/* <div className="p-4">
 | 
					
 | 
				
			||||||
                    <h2>Available Equipment</h2>
 | 
					 | 
				
			||||||
                    <MatchInfoCardDisplay recommendedmatches={this.state.displayedEquipment} />
 | 
					 | 
				
			||||||
                </div> */}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            </React.Fragment>
 | 
					            </React.Fragment>
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user