-
Notifications
You must be signed in to change notification settings - Fork 53
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
Exploding files: Part 2 (AdminPage) #179
Open
theredwillow
wants to merge
4
commits into
joshzcold:master
Choose a base branch
from
theredwillow:issue-70-explode-files
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d1a8592
refactor(AdminPage): Exploded file into manageable component files
theredwillow 8599f9a
Added missing i18n
theredwillow 11d77a0
Merge remote-tracking branch 'upstream/master' into issue-70-explode-…
theredwillow 30a4723
Added missing Image import
theredwillow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
94 changes: 94 additions & 0 deletions
94
src/components/Admin/GameDisplay/FinalRoundButtonControls.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { useTranslation } from "react-i18next"; | ||
|
||
function FinalRoundButtonControls({ game, send, setGame }) { | ||
const { t } = useTranslation(); | ||
const controlRound = game.is_final_second ? game.final_round_2 : game.final_round; | ||
return controlRound?.map((x, i) => ( | ||
<div | ||
key={`${game.is_final_second ? "final-round-2" : "final-round-1"}-question-${i}`} | ||
className="flex flex-col space-y-5 border-2 p-12" | ||
> | ||
<p className="text-3xl font-bold text-foreground">{x.question}</p> | ||
{game.is_final_second && ( | ||
<div className="flex flex-row space-x-5 pb-2"> | ||
{/* PARTNER'S ANSWER PROVIDED FINAL ROUND */} | ||
<div className="w-48 grow p-5 align-middle text-3xl text-foreground"> | ||
<i>{t("Partner's Answer")}</i>: {game.final_round[i].input || `(${t("No Answer")})`} | ||
</div> | ||
{game.final_round[i].input && ( | ||
<button | ||
id={`alreadyAnswered${i}Button`} | ||
className="grow rounded border-4 bg-secondary-300 p-5 text-2xl text-foreground" | ||
onClick={() => send({ action: "duplicate" })} | ||
> | ||
{t("Already Answered")} | ||
</button> | ||
)} | ||
</div> | ||
)} | ||
<div className="flex flex-row space-x-5 pb-2"> | ||
{/* ANSWER PROVIDED FINAL ROUND */} | ||
<input | ||
id={`finalRoundAnswer${i}Input`} | ||
className="w-48 grow rounded border-4 bg-secondary-300 p-5 text-2xl text-foreground placeholder:text-secondary-900" | ||
placeholder={t("Answer")} | ||
value={x.input} | ||
onChange={(e) => { | ||
x.input = e.target.value; | ||
setGame((prv) => ({ ...prv })); | ||
}} | ||
/> | ||
|
||
<button | ||
id={`finalRoundAnswer${i}RevealButton`} | ||
className="grow rounded border-4 bg-secondary-300 p-5 text-2xl text-foreground" | ||
onClick={() => { | ||
x.revealed = true; | ||
setGame((prv) => ({ ...prv })); | ||
send({ action: "data", data: game }); | ||
send({ action: "final_reveal" }); | ||
}} | ||
> | ||
{t("Reveal Answer")} | ||
</button> | ||
</div> | ||
<div className="flex flex-row space-x-5"> | ||
{/* POINTS AWARDED FINAL ROUND */} | ||
<select | ||
id={`finalRoundAnswer${i}Selector`} | ||
value={x.selection} | ||
className="w-48 grow rounded border-4 bg-secondary-300 p-5 text-2xl text-foreground" | ||
onChange={(e) => { | ||
x.selection = parseInt(e.target.value); | ||
setGame((prv) => ({ ...prv })); | ||
send({ action: "data", data: game }); | ||
}} | ||
> | ||
<option value={0}>({t("No Answer")}) 0</option> | ||
{x.answers.map((key, index) => ( | ||
<option key={`answers-${key}`} value={index + 1}> | ||
{x.answers[index][0]} {x.answers[index][1]} | ||
</option> | ||
))} | ||
</select> | ||
|
||
<button | ||
className="grow rounded border-4 bg-secondary-300 p-5 text-2xl text-foreground" | ||
id={`finalRoundAnswers${i}SubmitButton`} | ||
onClick={() => { | ||
x.points = x.selection !== -1 ? x.answers[x.selection][1] : 0; | ||
setGame((prv) => ({ ...prv })); | ||
send({ action: "data", data: game }); | ||
send({ | ||
action: x.selection !== -1 ? "final_submit" : "mistake", | ||
}); | ||
}} | ||
> | ||
{t("Award points")} | ||
</button> | ||
</div> | ||
</div> | ||
)); | ||
} | ||
|
||
export default FinalRoundButtonControls; |
53 changes: 53 additions & 0 deletions
53
src/components/Admin/GameDisplay/FinalRoundPointTotals.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { useTranslation } from "react-i18next"; | ||
|
||
function FinalRoundPointTotalsTextFunction({ title, total, isFinalSecond, place }) { | ||
const { t } = useTranslation(); | ||
const backgroundColor = | ||
(isFinalSecond && place === 1) || (!isFinalSecond && place === 0) | ||
? "bg-primary-200" | ||
: "bg-secondary-300"; | ||
return ( | ||
<div | ||
className={`flex flex-row items-center space-x-2 rounded-3xl border-2 p-4 text-2xl text-foreground ${backgroundColor} text-foreground`} | ||
> | ||
<p id={`finalRoundPointTotal${place}TitleText`}> | ||
{t(title)}:{" "} | ||
</p> | ||
<p id={`finalRoundPointTotal${place}TotalText`}> | ||
{total} | ||
</p> | ||
</div> | ||
); | ||
} | ||
|
||
const calculateTotalPoints = (rounds) => | ||
rounds.reduce((total, round) => total + parseInt(round.points), 0); | ||
|
||
function FinalRoundPointTotals({ game }) { | ||
const roundOneTotal = calculateTotalPoints(game.final_round); | ||
const roundTwoTotal = calculateTotalPoints(game.final_round_2); | ||
return ( | ||
<div className="flex flex-row items-center justify-start space-x-5 py-3"> | ||
<FinalRoundPointTotalsTextFunction | ||
title="Round one" | ||
total={roundOneTotal} | ||
isFinalSecond={game.is_final_second} | ||
place={0} | ||
/> | ||
<FinalRoundPointTotalsTextFunction | ||
title="Round two" | ||
total={roundTwoTotal} | ||
isFinalSecond={game.is_final_second} | ||
place={1} | ||
/> | ||
<FinalRoundPointTotalsTextFunction | ||
title="Total" | ||
total={roundOneTotal + roundTwoTotal} | ||
isFinalSecond={game.is_final_second} | ||
place={2} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
export default FinalRoundPointTotals; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { useTranslation } from "react-i18next"; | ||
|
||
function TeamControls({ game, setGame, team, send, setPointsGiven, pointsGiven }) { | ||
const { t } = useTranslation(); | ||
|
||
function TeamGetsPointsButton() { | ||
return ( | ||
<button | ||
disabled={pointsGiven.state} | ||
id={`team${team}GivePointsButton`} | ||
className={`border-4 text-2xl ${pointsGiven.color} rounded p-10 ${pointsGiven.textColor}`} | ||
onClick={() => { | ||
game.teams[team].points = | ||
game.point_tracker[game.round] + game.teams[team].points; | ||
setPointsGiven({ | ||
state: true, | ||
color: "bg-secondary-500", | ||
textColor: "text-foreground", | ||
}); | ||
setGame((prv) => ({ ...prv })); | ||
send({ action: "data", data: game }); | ||
}} | ||
> | ||
{t("team")} {t("number", { count: team + 1 })}: {game.teams[team].name} {t("Gets Points")} | ||
</button> | ||
); | ||
} | ||
|
||
function TeamMistakeButton() { | ||
return ( | ||
<button | ||
id={`team${team}MistakeButton`} | ||
className="rounded border-4 bg-failure-500 p-10 text-2xl text-foreground" | ||
onClick={() => { | ||
if (game.teams[team].mistakes < 3) game.teams[team].mistakes++; | ||
setGame((prv) => ({ ...prv })); | ||
send({ action: "data", data: game }); | ||
send({ | ||
action: "mistake", | ||
data: game.teams[team].mistake, | ||
}); | ||
}} | ||
> | ||
{t("team")} {t("number", { count: team + 1 })}: {game.teams[team].name} {t("mistake")} | ||
</button> | ||
); | ||
} | ||
|
||
return ( | ||
<> | ||
<TeamGetsPointsButton /> | ||
<TeamMistakeButton /> | ||
</> | ||
); | ||
} | ||
|
||
export default TeamControls; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { useTranslation } from "react-i18next"; | ||
|
||
function TitleMusic() { | ||
const { t } = useTranslation(); | ||
return ( | ||
<div className="flex flex-row items-center space-x-5 p-5"> | ||
<h3 className="text-2xl text-foreground">{t("Title Music")}</h3> | ||
<audio controls id="titleMusicAudio"> | ||
<source src="title.mp3" type="audio/mpeg" /> | ||
</audio> | ||
</div> | ||
); | ||
} | ||
|
||
export default TitleMusic; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not something you messed up, just noticed this. Is my assumption correct?