Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Arquisoft/wiq_es1a
Browse files Browse the repository at this point in the history
  • Loading branch information
CANCI0 committed Apr 2, 2024
2 parents cd30dee + 7b491c5 commit ea55fba
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions webapp/src/pages/Bateria/Bateria.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const JuegoPreguntas = () => {
}, []);

useEffect(() => {
if (tiempoRestante === 0) {
if (tiempoRestante == 0) {
setJuegoTerminado(true);
if(preguntasCorrectas+preguntasFalladas>0){
const preguntasTotales=preguntasCorrectas+preguntasFalladas;
Expand Down Expand Up @@ -186,7 +186,7 @@ const JuegoPreguntas = () => {
<Button
key={index}
onClick={() => handleSiguientePregunta(respuesta)}
disabled={tiempoRestante === 0 || juegoTerminado}
disabled={tiempoRestante == 0 || juegoTerminado}
>
{respuesta}
</Button>
Expand Down
8 changes: 4 additions & 4 deletions webapp/src/pages/Clasico/Clasico.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const JuegoPreguntas = () => {
}, [tiempoRestante]);

useEffect(() => {
if (tiempoRestante === 0) {
if (tiempoRestante == 0) {
const newTTotal=tiempoTotal+(SECS_PER_QUESTION);
setTiempoTotal(newTTotal);
setPreguntaTerminada(true);
Expand Down Expand Up @@ -224,7 +224,7 @@ const JuegoPreguntas = () => {
<p p={2}>
Tu puntuación: {puntuacion}/{preguntas.length}
</p>
{preguntasFalladas === 0 ? (
{preguntasFalladas == 0 ? (
<Box>
<Image src="/jordi.png" alt="Jordi Hurtado" />
<Text>¡Has acertado todas! Eres la cuenta secundaria de Jordi Hurtado.</Text>
Expand All @@ -248,7 +248,7 @@ const JuegoPreguntas = () => {
<Button
key={index}
onClick={() => handleRespuestaSeleccionada(respuesta)}
disabled={tiempoRestante === 0 || juegoTerminado}
disabled={tiempoRestante == 0 || juegoTerminado}
style={estiloRespuesta(respuesta)}
>
{respuesta}
Expand All @@ -262,7 +262,7 @@ const JuegoPreguntas = () => {
const newTTotal=tiempoTotal+(SECS_PER_QUESTION-tiempoRestante);
setTiempoTotal(newTTotal);
setTiempoRestante(0)}}
disabled={tiempoRestante === 0 || juegoTerminado}
disabled={tiempoRestante == 0 || juegoTerminado}
colorScheme="teal"
m={2}
>
Expand Down
16 changes: 9 additions & 7 deletions webapp/src/pages/Stats/Stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ const Stats = () => {
const [error, setError] = useState(null);
const [fetched, setFetched] = useState(false);

const fetchStats = () => {
const fetchStats = (mode) => {
setIsLoading(true);
fetch(gatewayUrl + `/stats?user=${username}&gamemode=${gamemode}`)
fetch(gatewayUrl + `/stats?user=${username}&gamemode=${mode}`)
.then((response) => response.json())
.then((data) => {
setStats(data);
Expand All @@ -42,7 +42,7 @@ const Stats = () => {

useEffect(() => {
if (!fetched) {
fetchStats();
fetchStats(gamemode);
setFetched(true);
}
// eslint-disable-next-line
Expand All @@ -52,14 +52,16 @@ const Stats = () => {
setUsername(event.target.value);
};

const handleGamemodeChange = (mode) => {
const handleGamemodeChange = async (mode) => {
if (mode === gamemode) return;

setGamemode(mode);
// Llama a fetchStats() para actualizar las estadísticas cuando se cambia el modo de juego
fetchStats();
fetchStats(mode);
};


const handleSearch = () => {
fetchStats();
fetchStats(gamemode);
};

const getModeName = () => {
Expand Down

0 comments on commit ea55fba

Please sign in to comment.