Merge remote-tracking branch 'origin/restructure' into Dashboard
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
import React from "react";
|
||||
import propTypes from "prop-types";
|
||||
import GameInfoCard from "./GameInfoCard";
|
||||
|
||||
export default class GameInfoCardDisplay extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
<div className="horizontal-scroller">
|
||||
{this.props.recommendedMatches.map((match) => <GameInfoCard key={match.id} match={match}></GameInfoCard>)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
GameInfoCardDisplay.propTypes = {
|
||||
recommendedMatches: propTypes.array,
|
||||
};
|
@@ -1,18 +1,17 @@
|
||||
import React from "react";
|
||||
import { Carousel } from "react-bootstrap";
|
||||
import "../styles/HomeCarousel.css";
|
||||
export default class HomeCarousel extends React.Component{
|
||||
export default class HomeCarousel extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
<Carousel>
|
||||
<Carousel className="jumbotron" variant="light">
|
||||
<Carousel.Item>
|
||||
<img
|
||||
src='https://www.allanpanthera.com/wp-content/uploads/elementor/thumbs/79377445_m-o6r0ydib97moj7m7zg58w32qirim121wxt2i8thqyg.jpg'
|
||||
className="d-block w-100"
|
||||
src='/images/carousel/volleyball_normalized.jpg'
|
||||
alt="Connect Slide"
|
||||
style={{ height: "300px", width: "2000px"}}
|
||||
/>
|
||||
<Carousel.Caption>
|
||||
<div className="captionStyle">
|
||||
@@ -23,9 +22,9 @@ export default class HomeCarousel extends React.Component{
|
||||
</Carousel.Item>
|
||||
<Carousel.Item>
|
||||
<img
|
||||
src='http://cpadollard.com/wp-content/uploads/2018/01/cpa-dollard-fsc-banner-calendar_2000x300.jpg'
|
||||
className="d-block w-100"
|
||||
src='/images/carousel/schedule_normalized.jpg'
|
||||
alt="Schedule Slide"
|
||||
style={{ height: "300px", width: "2000px" }}
|
||||
/>
|
||||
<Carousel.Caption>
|
||||
<div className="captionStyle">
|
||||
@@ -36,9 +35,9 @@ export default class HomeCarousel extends React.Component{
|
||||
</Carousel.Item>
|
||||
<Carousel.Item>
|
||||
<img
|
||||
src='https://tadvantagesites-com.cdn-convertus.com/uploads/sites/288/2019/07/Generic-Personal-Watercraft-3.jpg'
|
||||
src='/images/carousel/rentals_normalized.jpg'
|
||||
alt="Rent Slide"
|
||||
style={{ height: "300px", width: "2000px" }}
|
||||
className="d-block w-100"
|
||||
/>
|
||||
<Carousel.Caption>
|
||||
<div className="captionStyle">
|
||||
|
@@ -2,14 +2,15 @@ import React from "react";
|
||||
import { Button, Card } from "react-bootstrap";
|
||||
import propTypes from "prop-types";
|
||||
import { grammaticalListString } from "../utils/strings";
|
||||
export default class GameInfoCard extends React.Component {
|
||||
export default class MatchInfoCard extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
getParticipants() {
|
||||
let participants = [];
|
||||
this.props.match.registeredUsers.array.forEach(user => {
|
||||
console.log(this.props);
|
||||
this.props.match.participants.forEach(user => {
|
||||
participants.push(user.firstName);
|
||||
});
|
||||
return participants;
|
||||
@@ -19,10 +20,10 @@ export default class GameInfoCard extends React.Component {
|
||||
return (
|
||||
<Card style={{ width: "20rem" }}>
|
||||
<Card.Body>
|
||||
<Card.Title>{this.props.match.sport}</Card.Title>
|
||||
<Card.Subtitle className="mb-2 text-muted">{this.props.match.sport}</Card.Subtitle>
|
||||
<Card.Title>{this.props.match.sport.name}</Card.Title>
|
||||
<Card.Subtitle className="mb-2 text-muted">{this.props.match.title}</Card.Subtitle>
|
||||
<Card.Text>
|
||||
Join <strong>{grammaticalListString(this.getParticipants(), 4)}</strong> to play a few matches of <strong>{this.props.match.sport}</strong> at <strong>{this.props.match.location}</strong> on <strong>{this.props.match.dateTime.toLocaleDateString("en-US")}</strong>!
|
||||
Join <strong>{grammaticalListString(this.getParticipants(), 4)}</strong> to play a few matches of <strong>{this.props.match.sport.name}</strong> at <strong>{this.props.match.location.toString()}</strong> on <strong>{new Date(this.props.match.when).toLocaleDateString("en-US")}</strong>!
|
||||
</Card.Text>
|
||||
<Button variant="primary">Join!</Button>
|
||||
</Card.Body>
|
||||
@@ -31,6 +32,6 @@ export default class GameInfoCard extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
GameInfoCard.propTypes = {
|
||||
MatchInfoCard.propTypes = {
|
||||
match: propTypes.object,
|
||||
};
|
24
sports-matcher/client/src/components/MatchInfoCardDisplay.js
Normal file
24
sports-matcher/client/src/components/MatchInfoCardDisplay.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import React from "react";
|
||||
import propTypes from "prop-types";
|
||||
import MatchInfoCard from "./MatchInfoCard";
|
||||
|
||||
export default class MatchInfoCardDisplay extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
render() {
|
||||
let matches = null;
|
||||
if (this.props.recommendedmatches.length > 0) {
|
||||
matches = this.props.recommendedmatches.map((match) => <MatchInfoCard key={match._id} match={match}></MatchInfoCard>);
|
||||
}
|
||||
return (
|
||||
<div className="horizontal-scroller">
|
||||
{matches}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
MatchInfoCardDisplay.propTypes = {
|
||||
recommendedmatches: propTypes.array,
|
||||
};
|
@@ -4,6 +4,9 @@ import Layout from "./Layout";
|
||||
import reportWebVitals from "./reportWebVitals";
|
||||
import { BrowserRouter } from "react-router-dom";
|
||||
import "bootstrap/dist/css/bootstrap.min.css"; // This could be optimized by importing individual css components.
|
||||
|
||||
console.log(process.env);
|
||||
|
||||
ReactDOM.render(
|
||||
<React.StrictMode>
|
||||
<BrowserRouter>
|
||||
|
@@ -1,20 +1,31 @@
|
||||
import React from "react";
|
||||
import { apiClient } from "../utils/httpClients";
|
||||
import HomeCarousel from "../components/HomeCarousel";
|
||||
import MatchInfoCardDisplay from "../components/MatchInfoCardDisplay";
|
||||
export default class Welcome extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.recentMatchesRequest = apiClient.get("/match/recent/15");
|
||||
this.state = {
|
||||
displayedMatches: [],
|
||||
};
|
||||
}
|
||||
|
||||
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 });
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className="page-root">
|
||||
<div>
|
||||
{/* <h1>Sports Matcher</h1>
|
||||
<p>The best place to find a local match for a good game of your favourite sport!</p> */}
|
||||
<HomeCarousel></HomeCarousel>
|
||||
</div>
|
||||
<HomeCarousel />
|
||||
<div className="text-center p-3 mt-2">
|
||||
<h2>Why?</h2>
|
||||
<p>Because you want to play the sports you love while meeting new friends!</p>
|
||||
@@ -23,6 +34,7 @@ export default class Welcome extends React.Component {
|
||||
<hr />
|
||||
<div className="p-4">
|
||||
<h2>Available Matches</h2>
|
||||
<MatchInfoCardDisplay recommendedmatches={this.state.displayedMatches} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
@@ -1,15 +0,0 @@
|
||||
.captionStyle {
|
||||
background-color: seashell;
|
||||
color: black;
|
||||
outline: 1px solid black;
|
||||
}
|
||||
|
||||
.carousel-control-next,
|
||||
.carousel-control-prev /*, .carousel-indicators */ {
|
||||
filter: invert(100%);
|
||||
}
|
||||
|
||||
.carousel-indicators button {
|
||||
filter: invert(100%);
|
||||
}
|
||||
|
@@ -1,19 +1,5 @@
|
||||
.jumbotron {
|
||||
width: 100%;
|
||||
padding-left: 1.5rem;
|
||||
padding-right: 1.5rem;
|
||||
padding-top: 12rem;
|
||||
padding-bottom: 1rem;
|
||||
text-align: center;
|
||||
background-size: cover;
|
||||
background-color: black;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.jumbotron h1 {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
.horizontal-scroller {
|
||||
overflow-x: scroll;
|
||||
padding-top: 1rem;
|
||||
padding-bottom: 1rem;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import axios from "axios";
|
||||
|
||||
export const apiClient = axios.create({
|
||||
baseURL: process.env.API_HOST,
|
||||
baseURL: process.env.REACT_APP_API_HOST,
|
||||
timeout: 5000,
|
||||
});
|
@@ -10,7 +10,9 @@ export function grammaticalListString(items, max) {
|
||||
return;
|
||||
}
|
||||
built += item;
|
||||
built += ", ";
|
||||
if (index < items.length - 1) {
|
||||
built += ", ";
|
||||
}
|
||||
if (index == max - 1) {
|
||||
built += "and ";
|
||||
}
|
||||
|
Reference in New Issue
Block a user