|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- import React, {useState} from "react";
- import StartButton from "./StartButton";
- import QuitButton from "./QuitButton";
- import TeamSizePopUp from "./TeamsizePopUp";
-
- function Buttons({startQuestion, timerRunning, stopTimer, setQuestionCount, setTeamSize}) {
- const [gameStarted, setGameStarted] = useState(false)
- const [openPopUp, setOpenPopUp] = useState(false)
- const [quitvisible, setQuitvisible] = useState(false)
-
- const changeGame = (bool) => {
- setGameStarted(bool)
- setQuitvisible(bool)
- }
-
- const startClicked = () => {
- if(!timerRunning && !gameStarted) {
- setOpenPopUp(true);
- }
- else if (!timerRunning && gameStarted) {
- startQuestion();
- }
- }
-
- const quitGame = () => {
- changeGame(false);
- stopTimer();
- setQuestionCount(0);
- }
-
-
- return(
- <div className="Buttons">
- <StartButton
- onClick={startClicked}
- content={(gameStarted) ? "Nächste Frage" : "Spiel Starten" }
- />
- {quitvisible && <QuitButton quitGame={quitGame}/>}
- {openPopUp && <TeamSizePopUp closeModal={setOpenPopUp}
- changeGameState={changeGame}
- startQuestion={startQuestion}
- setTeamSize={setTeamSize}
- />}
- </div>
- )
- }
-
- export default Buttons
|