repository to manage all files for 1_2_oder_3 interaction game for Inf2/2 Interaktionen SoSe23 from Engert, Caliskan and Bachiri
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TeamsizePopUp.js 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import React, {useState} from "react";
  2. import {postTeamsize} from "./api";
  3. function TeamSizePopUp({closeModal, changeGameState, startQuestion, setTeamSize}) {
  4. const [inputValue, setInputValue] = useState(2);
  5. const getInput = (event) => {
  6. setInputValue(event.target.value);
  7. }
  8. const closePopUp = () => {
  9. closeModal(false);
  10. }
  11. const TeamSizeButtonClicked = () => {
  12. if(inputValue <= 2 && inputValue > 0){
  13. /*
  14. postTeamsize({
  15. "Teamsize": inputValue
  16. }).then(data => console.log("Received answer" + data))
  17. */
  18. setTeamSize(inputValue)
  19. changeGameState(true);
  20. closePopUp();
  21. startQuestion();
  22. }
  23. else {
  24. alert("Bitte Zahl zwischen 1 und 2 eingeben ! ")
  25. }
  26. }
  27. return (
  28. <div className="PopUpBackground">
  29. <div className="PopUpContainer">
  30. <div>
  31. <div id="Cancel" onClick={closePopUp}>X</div>
  32. <h2>Bitte Teamgröße wählen </h2>
  33. </div>
  34. <div>
  35. <input type="number" id="TeamSizeInput" min={1} max={2} value={inputValue}
  36. onChange={getInput}/>
  37. </div>
  38. <div>
  39. <button className="MyButton" id="PopUpButton" onClick={TeamSizeButtonClicked}>Bestätigen und Spiel starten</button>
  40. </div>
  41. </div>
  42. </div>
  43. )
  44. }
  45. export default TeamSizePopUp