diff --git a/webapp/src/components/Login.js b/webapp/src/components/Login.js index 740eb12..f5173be 100644 --- a/webapp/src/components/Login.js +++ b/webapp/src/components/Login.js @@ -81,7 +81,7 @@ const Login = ({isLogged, setIsLogged, username, setUsername}) => { }; Login.propTypes = { - isLogged: PropTypes.string.isRequired, + isLogged: PropTypes.bool, setIsLogged: PropTypes.func, username: PropTypes.string, setUsername: PropTypes.func diff --git a/webapp/src/components/Pages/Estadisticas.js b/webapp/src/components/Pages/Estadisticas.js index a5c4761..866ecf9 100644 --- a/webapp/src/components/Pages/Estadisticas.js +++ b/webapp/src/components/Pages/Estadisticas.js @@ -1,4 +1,3 @@ -// src/components/Login.js import React, { useState, useEffect } from 'react'; import { Container } from '@mui/material'; import '../Estilos/estadisticas.css'; @@ -66,7 +65,7 @@ const Estadisticas = ({isLogged, username}) => { }; Estadisticas.propTypes = { - isLogged: PropTypes.string.isRequired, + isLogged: PropTypes.bool, username: PropTypes.string } diff --git a/webapp/src/components/Pages/Home.js b/webapp/src/components/Pages/Home.js index 8fa7c3b..6922bcc 100644 --- a/webapp/src/components/Pages/Home.js +++ b/webapp/src/components/Pages/Home.js @@ -69,7 +69,7 @@ const Home = ({isLogged, setIsLogged}) => { }; Home.propTypes = { - isLogged: PropTypes.string, + isLogged: PropTypes.bool, setIsLogged: PropTypes.func, } diff --git a/webapp/src/components/Pages/Juego.js b/webapp/src/components/Pages/Juego.js index 3e9e053..0f4c1d2 100644 --- a/webapp/src/components/Pages/Juego.js +++ b/webapp/src/components/Pages/Juego.js @@ -5,6 +5,7 @@ import '../Estilos/juego.css'; import { Container } from '@mui/material'; import Temporizador from '../Temporizador'; import PropTypes from 'prop-types' +import {useNavigate} from 'react-router-dom' const Juego = ({isLogged, username, numPreguntas}) => { //La pregunta (string) @@ -27,6 +28,9 @@ const Juego = ({isLogged, username, numPreguntas}) => { const [finishGame, setFinishGame] = useState(false) const [numRespuestasCorrectas, setNumRespuestasCorrectas] = useState(0) const [numRespuestasIncorrectas, setNumRespuestasIncorrectas] = useState(0) + const [disableFinish, setDisableFinish] = useState(false) + + const navigate= useNavigate() //Variables para la obtencion y modificacion de estadisticas del usuario const apiEndpoint = process.env.REACT_APP_API_ENDPOINT || 'http://localhost:8000'; @@ -199,14 +203,14 @@ const Juego = ({isLogged, username, numPreguntas}) => { //Funcion que se llama al hacer click en el boton Siguiente const clickFinalizar = () => { updateStats(); + setDisableFinish(true) + navigate('/') } const handleRestart = () => { setRestartTemporizador(false); // Cambia el estado de restart a false, se llama aqui desde Temporizador.js }; - - return ( {ready ? <> @@ -224,14 +228,15 @@ const Juego = ({isLogged, username, numPreguntas}) => { :

CARGANDO...

} {finishGame ? <>

PARTIDA FINALIZADA

- +

ACERTADAS: {numRespuestasCorrectas} FALLADAS: {numRespuestasIncorrectas}

+ : <>}
); }; Juego.propTypes = { - isLogged: PropTypes.string, + isLogged: PropTypes.bool, username: PropTypes.string, numPreguntas: PropTypes.number } diff --git a/webapp/src/components/Pages/Layout.js b/webapp/src/components/Pages/Layout.js index 206fb4c..d49490d 100644 --- a/webapp/src/components/Pages/Layout.js +++ b/webapp/src/components/Pages/Layout.js @@ -42,7 +42,7 @@ import PropTypes from 'prop-types' }; Layout.propTypes = { - isLogged: PropTypes.string.isRequired, + isLogged: PropTypes.bool, setIsLogged: PropTypes.func } diff --git a/webapp/src/components/Temporizador.js b/webapp/src/components/Temporizador.js index 353d485..e56fd34 100644 --- a/webapp/src/components/Temporizador.js +++ b/webapp/src/components/Temporizador.js @@ -7,7 +7,6 @@ const Temporizador =({restart, tiempoInicial, tiempoAcabado, pausa, handleRestar useEffect(() => { let intervalID; - console.log("estado tempo: " + restart) if(restart){ setTiempoSegundos(tiempoInicial); pausa=false;