From f35edf30e1b6a6223bebd794a7d0a915ff2d0596 Mon Sep 17 00:00:00 2001 From: alegarman2002 <116609314+alegarman2002@users.noreply.github.com> Date: Mon, 29 Apr 2024 20:35:16 +0200 Subject: [PATCH] Fixed problem with game number of questions if we switch view --- webapp/src/components/FirstGame.js | 6 +++++- webapp/src/components/game/GameConfiguration.js | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/webapp/src/components/FirstGame.js b/webapp/src/components/FirstGame.js index a5bf771a..ffcb5e46 100644 --- a/webapp/src/components/FirstGame.js +++ b/webapp/src/components/FirstGame.js @@ -7,7 +7,6 @@ import { useLocation, useNavigate } from 'react-router-dom'; import Button from './Button'; import { Footer } from './footer/Footer'; import { Nav } from './nav/Nav'; -import {esperar} from './Util'; let currentQuestionIndex = 0; @@ -52,6 +51,10 @@ const Quiz = () => { clearInterval(time); }; }); + + const esperar = (ms) => { + return new Promise(resolve => setTimeout(resolve, ms)); + }; function changeButtons(param) { var borders = document.getElementsByClassName("border");; @@ -108,6 +111,7 @@ const Quiz = () => { haveFailedQuestion = false; load = true haveEnter = false + console.log("Calbo") if (currentQuestionIndex === allQuestions.length ) { console.log("Entramos aqui") diff --git a/webapp/src/components/game/GameConfiguration.js b/webapp/src/components/game/GameConfiguration.js index c51d84f4..5a2d88b8 100644 --- a/webapp/src/components/game/GameConfiguration.js +++ b/webapp/src/components/game/GameConfiguration.js @@ -13,10 +13,10 @@ import { generateGameId } from '../Util'; const apiEndpoint = process.env.REACT_APP_API_ENDPOINT|| 'http://localhost:8000'; let gameId; -let questions = [] -const GameConfiguration = () => { +const GameConfiguration = () => { + let questions = [] const navigation = useNavigate(); let tematicas = ['Paises', 'Capitales']; let state = useLocation().state;