Created untested GameInfoCard.
With required data structures and functions.
This commit is contained in:
parent
2fed0619a0
commit
abf238b1fb
36
client/src/components/GameInfoCard.js
Normal file
36
client/src/components/GameInfoCard.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
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 {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
}
|
||||||
|
|
||||||
|
getParticipants() {
|
||||||
|
let participants = [];
|
||||||
|
this.props.match.registeredUsers.array.forEach(user => {
|
||||||
|
participants.push(user.firstName);
|
||||||
|
});
|
||||||
|
return participants;
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
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.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>!
|
||||||
|
</Card.Text>
|
||||||
|
<Button variant="primary">Join!</Button>
|
||||||
|
</Card.Body>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GameInfoCard.propTypes = {
|
||||||
|
match: propTypes.object,
|
||||||
|
};
|
10
client/src/models/Match.js
Normal file
10
client/src/models/Match.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
export default class Match {
|
||||||
|
minUsers;
|
||||||
|
MaxUsers;
|
||||||
|
registeredUsers;
|
||||||
|
dateTime;
|
||||||
|
duration;
|
||||||
|
sport;
|
||||||
|
difficulty;
|
||||||
|
title;
|
||||||
|
}
|
8
client/src/models/User.js
Normal file
8
client/src/models/User.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
export default class User {
|
||||||
|
firstName;
|
||||||
|
lastName;
|
||||||
|
email;
|
||||||
|
age;
|
||||||
|
biography;
|
||||||
|
id;
|
||||||
|
}
|
@ -8,10 +8,19 @@ export default class Welcome extends React.Component {
|
|||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="page-root">
|
<div className="page-root">
|
||||||
<div id="welcome-jumbotron" className="jumbotron" >
|
<div className="jumbotron" >
|
||||||
<h1>Sports Matcher</h1>
|
<h1>Sports Matcher</h1>
|
||||||
<p>The best place to find a local match for a good game of your favourite sport!</p>
|
<p>The best place to find a local match for a good game of your favourite sport!</p>
|
||||||
</div>
|
</div>
|
||||||
|
<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 and foes!</p>
|
||||||
|
{/* TODO: All this text should be expanded on. */}
|
||||||
|
</div>
|
||||||
|
<hr />
|
||||||
|
<div className="p-4">
|
||||||
|
<h2>Available Matches</h2>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
padding-left: 1.5rem;
|
padding-left: 1.5rem;
|
||||||
padding-right: 1.5rem;
|
padding-right: 1.5rem;
|
||||||
padding-top: 10rem;
|
padding-top: 12rem;
|
||||||
padding-bottom: 0.75rem;
|
padding-bottom: 1rem;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
background-color: black;
|
background-color: black;
|
||||||
|
22
client/src/utils/strings.js
Normal file
22
client/src/utils/strings.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
export function grammaticalListString(items, max) {
|
||||||
|
if (!items) return null;
|
||||||
|
if (max < 1) return "";
|
||||||
|
let built = "";
|
||||||
|
|
||||||
|
let index = 0;
|
||||||
|
items.forEach(item => {
|
||||||
|
if (index > max) {
|
||||||
|
built += "and " + items.length + " more ";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
built += item;
|
||||||
|
built += ", ";
|
||||||
|
if (index == max - 1) {
|
||||||
|
built += "and ";
|
||||||
|
}
|
||||||
|
|
||||||
|
index += 1;
|
||||||
|
});
|
||||||
|
|
||||||
|
return built;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user