|
@@ -3,6 +3,8 @@ import styled from "styled-components";
|
|
import ClickToCopy from "../../util/ClickToCopy";
|
|
import ClickToCopy from "../../util/ClickToCopy";
|
|
import usePlayerScores from "../../../hooks/usePlayerScores";
|
|
import usePlayerScores from "../../../hooks/usePlayerScores";
|
|
import DelayedButton from "../../util/DelayedButton";
|
|
import DelayedButton from "../../util/DelayedButton";
|
|
|
|
+import useRoundInfo from "../../../hooks/useRoundInfo";
|
|
|
|
+import Button from "../../util/Button";
|
|
|
|
|
|
const useTopScorer = (gameId, roundNum) => {
|
|
const useTopScorer = (gameId, roundNum) => {
|
|
const scores = usePlayerScores(gameId);
|
|
const scores = usePlayerScores(gameId);
|
|
@@ -41,6 +43,11 @@ const TimedOut = styled.span`
|
|
color: red;
|
|
color: red;
|
|
`
|
|
`
|
|
|
|
|
|
|
|
+const FinishedButton = styled(Button)`
|
|
|
|
+ margin-top: 5px;
|
|
|
|
+ padding: 1em;
|
|
|
|
+`
|
|
|
|
+
|
|
const NextButton = styled(DelayedButton)`
|
|
const NextButton = styled(DelayedButton)`
|
|
margin-top: 5px;
|
|
margin-top: 5px;
|
|
padding: 1em;
|
|
padding: 1em;
|
|
@@ -48,6 +55,7 @@ const NextButton = styled(DelayedButton)`
|
|
|
|
|
|
export default ({
|
|
export default ({
|
|
gameId,
|
|
gameId,
|
|
|
|
+ playerName,
|
|
selectedPoint,
|
|
selectedPoint,
|
|
targetPoint,
|
|
targetPoint,
|
|
roundNum,
|
|
roundNum,
|
|
@@ -56,6 +64,7 @@ export default ({
|
|
onNext
|
|
onNext
|
|
}) => {
|
|
}) => {
|
|
const { topPlayer, topScore } = useTopScorer(gameId, roundNum);
|
|
const { topPlayer, topScore } = useTopScorer(gameId, roundNum);
|
|
|
|
+ const [gameFinished] = useRoundInfo(gameId, playerName)
|
|
|
|
|
|
return (
|
|
return (
|
|
<Container>
|
|
<Container>
|
|
@@ -69,12 +78,15 @@ export default ({
|
|
<span>Score For Round {roundNum}: {score}</span>
|
|
<span>Score For Round {roundNum}: {score}</span>
|
|
<span>Running Total Score: {totalScore}</span>
|
|
<span>Running Total Score: {totalScore}</span>
|
|
{topPlayer ? <span className="round-summary__top-score">Current best is {topPlayer} with {topScore}</span> : null}
|
|
{topPlayer ? <span className="round-summary__top-score">Current best is {topPlayer} with {topScore}</span> : null}
|
|
- <NextButton
|
|
|
|
- onEnd={onNext}
|
|
|
|
- countDownFormatter={rem => `Click to cancel, ${rem}s...`}
|
|
|
|
- >
|
|
|
|
- {roundNum === "5" ? "View Summary" : "Next Round"}
|
|
|
|
- </NextButton>
|
|
|
|
|
|
+ {
|
|
|
|
+ gameFinished
|
|
|
|
+ ? <FinishedButton onClick={onNext}>
|
|
|
|
+ View Summary
|
|
|
|
+ </FinishedButton>
|
|
|
|
+ : <NextButton onEnd={onNext} countDownFormatter={rem => `Click to cancel, ${rem}s...`}>
|
|
|
|
+ Next Round
|
|
|
|
+ </NextButton>
|
|
|
|
+ }
|
|
</Container>
|
|
</Container>
|
|
);
|
|
);
|
|
}
|
|
}
|