From 92cce230eec3adf794d20888c088f0e6b8896de3 Mon Sep 17 00:00:00 2001 From: uo264915 Date: Sun, 7 Apr 2024 14:10:14 +0200 Subject: [PATCH] Resolucion problemas fin de partida --- .github/workflows/release.yml | 4 -- webapp/src/components/Game.js | 22 ++++++----- webapp/src/components/HistoricalQuestions.js | 39 -------------------- webapp/src/components/MainPage.js | 7 ---- 4 files changed, 12 insertions(+), 60 deletions(-) delete mode 100644 webapp/src/components/HistoricalQuestions.js diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d79bea68..fc3e6a08 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -169,8 +169,4 @@ jobs: docker compose --profile prod down docker compose --profile prod up -d --pull always - wget https://raw.githubusercontent.com/arquisoft/wiq_0/master/docker-compose.yml -O docker-compose.yml - wget https://raw.githubusercontent.com/arquisoft/wiq_0/master/.env -O .env - docker compose --profile prod down - docker compose --profile prod up -d --pull always diff --git a/webapp/src/components/Game.js b/webapp/src/components/Game.js index d394909d..a96ed7ba 100644 --- a/webapp/src/components/Game.js +++ b/webapp/src/components/Game.js @@ -23,8 +23,8 @@ const Game = () => { const [questionCounter, setQuestionCounter] = useState(0); const [incorrectCounter, setIncorrectCounter] = useState(0); - const [numberOfQuestions, setNumberOfQuestions] = useState(10); - const [questionsToAnswer, setQuestionsToAnswer] = useState(10); + const [numberOfQuestions] = useState(3); + const [questionsToAnswer, setQuestionsToAnswer] = useState(3); const [isFinished, setFinished] = useState(false); const [percentage, setPercentage] = useState(0); @@ -55,9 +55,16 @@ const Game = () => { useEffect(() => { if (isGameFinished() && !isFinished){ finishGame(); - setFinished(true) + setFinished(true); ; } }, [correctCounter]); + + useEffect(() => { + if (isGameFinished() && !isFinished){ + finishGame(); + setFinished(true); +; } + }, [incorrectCounter]); // This method will call the create question service const handleShowQuestion = async () => { @@ -84,11 +91,8 @@ const Game = () => { button.onmouse = colorOnMousePreguntas; }); - - incrementQuestion(); - }catch (error){ console.error('Error:', error); } @@ -134,13 +138,11 @@ const Game = () => { decrementQuestionsToAnswer(); - - if (!isFinished){ + if (!isGameFinished()) { setTimeout(() => { handleShowQuestion(); - }, 850); + }, 1000); } - } const isGameFinished = () => { diff --git a/webapp/src/components/HistoricalQuestions.js b/webapp/src/components/HistoricalQuestions.js deleted file mode 100644 index 2e734412..00000000 --- a/webapp/src/components/HistoricalQuestions.js +++ /dev/null @@ -1,39 +0,0 @@ -import axios from 'axios'; -import React, { useState} from 'react'; -import { useNavigate} from 'react-router-dom'; -import { Container, Button} from '@mui/material'; - -const HistoricalQuestions = () => { - const navigate = useNavigate(); - const apiEndpoint = process.env.REACT_APP_API_ENDPOINT || 'http://localhost:8000'; - - const [questionsHistory, setQuestionsHistory] = useState([]); - - const handleShowHistory = async () => { - try{ - // It makes a petition to the api and store the response - const response = await axios.post(`${apiEndpoint}/getquestionshistory`, { }); - setQuestionsHistory(response.data); - }catch (error){ - console.error('Error:', error); - } - } - - const handlePreviousPage = async () => { - let path= '/MainPage'; - navigate(path); - } - - return ( - - - -
- -
-
- - ); -}; - -export default HistoricalQuestions; \ No newline at end of file diff --git a/webapp/src/components/MainPage.js b/webapp/src/components/MainPage.js index 6a2231c8..9bba6333 100644 --- a/webapp/src/components/MainPage.js +++ b/webapp/src/components/MainPage.js @@ -21,10 +21,6 @@ const MainPage = () => { navigate(path); }; - const handleShowHistoricalQuestions = () => { - let path= '/HistoricalQuestions'; - navigate(path); - }; return ( @@ -46,9 +42,6 @@ const MainPage = () => { - )