Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tied match cases #14

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/frontend/src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@

.lost-card {
background-color: #a34d5d;
}
}
.tie-card {
background-color: #f7af15;
}
15 changes: 10 additions & 5 deletions src/frontend/src/components/MatchDetailCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,22 @@ export const MatchDetailCard = ({teamName, match}) => {
const otherTeam = match.team1 === teamName ? match.team2 : match.team1;
const otherTeamRoute = `/teams/${otherTeam}`;
const isMatchWon = teamName === match.matchWinner;
const isTie = match.result === 'tie' ? true : false;
var cardColour = isTie ? 'MatchDetailCard tie-card' : isMatchWon ? 'MatchDetailCard won-card' : 'MatchDetailCard lost-card';
var matchResult = "";
if(isTie) {
matchResult = "There was a tie between " + match.team1 + " and " + match.team2;
} else {
matchResult = match.matchWinner + " won by " + match.resultMargin + " " + match.result;
}
return (
<div className={isMatchWon ? 'MatchDetailCard won-card' : 'MatchDetailCard lost-card'}>
<div className={cardColour}>
<div>
<span className="vs">vs</span>
<h1><Link to={otherTeamRoute}>{otherTeam}</Link></h1>
<h2 className="match-date">{match.date}</h2>
<h3 className="match-venue">at {match.venue}</h3>
<h3 className="match-result">{match.matchWinner} won by {match.resultMargin} {match.result} </h3>
<h3 className="match-result">{matchResult} </h3>
</div>
<div className="additional-detail">
<h3>First Innings</h3>
Expand All @@ -26,10 +34,7 @@ export const MatchDetailCard = ({teamName, match}) => {
<p>{match.playerOfMatch}</p>
<h3>Umpires</h3>
<p>{match.umpire1}, {match.umpire2}</p>


</div>

</div>
);
}
12 changes: 10 additions & 2 deletions src/frontend/src/components/MatchSmallCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,19 @@ export const MatchSmallCard = ({match, teamName}) => {
const otherTeam = match.team1 === teamName ? match.team2 : match.team1;
const otherTeamRoute = `/teams/${otherTeam}`;
const isMatchWon = teamName === match.matchWinner;
const isTie = match.result === 'tie' ? true : false;
var cardColour = isTie ? 'MatchSmallCard tie-card' : isMatchWon ? 'MatchSmallCard won-card' : 'MatchSmallCard lost-card';
var matchResult = "";
if(isTie) {
matchResult = "There was a tie between " + match.team1 + " and " + match.team2;
} else {
matchResult = match.matchWinner + " won by " + match.resultMargin + " " + match.result;
}
return (
<div className={isMatchWon ? 'MatchSmallCard won-card' : 'MatchSmallCard lost-card'}>
<div className={cardColour}>
<span className="vs">vs</span>
<h1><Link to={otherTeamRoute}>{otherTeam}</Link></h1>
<p className="match-result">{match.matchWinner} won by {match.resultMargin} {match.result} </p>
<p className="match-result">{ matchResult } </p>

</div>
);
Expand Down