|
1 |
| -import React, { useState, useEffect, useMemo } from "react"; |
| 1 | +import React, { useState, useEffect } from "react"; |
2 | 2 | import Nav from "../../components/Nav/Nav.js";
|
3 | 3 | import { Link, useNavigate } from "react-router-dom";
|
4 | 4 | import Footer from "../../components/Footer/Footer.js";
|
5 |
| -import { Box, Flex, Heading, Button, Grid, useColorMode, Text, Image } from "@chakra-ui/react"; |
| 5 | +import { Box, Flex, Heading, Button, Grid, useColorMode, Text, Image, Spinner } from "@chakra-ui/react"; |
6 | 6 | import axios from "axios";
|
7 | 7 |
|
8 | 8 | const JuegoPreguntas = () => {
|
9 | 9 | const URL = process.env.REACT_APP_API_ENDPOINT || "http://localhost:8000";
|
10 |
| - const SECS_PER_QUESTION = useMemo(() => localStorage.getItem("clasicoTime")); |
| 10 | + const SECS_PER_QUESTION = localStorage.getItem("clasicoTime"); |
11 | 11 | const { colorMode } = useColorMode();
|
12 | 12 | const isDarkTheme = colorMode === "dark";
|
13 | 13 |
|
@@ -54,7 +54,6 @@ const JuegoPreguntas = () => {
|
54 | 54 | setIsLoading(false);
|
55 | 55 | })
|
56 | 56 | .catch((error) => {
|
57 |
| - console.error("Error al obtener las preguntas:", error); |
58 | 57 | navigate("/home?error=1");
|
59 | 58 | });
|
60 | 59 | // eslint-disable-next-line
|
@@ -140,20 +139,18 @@ const JuegoPreguntas = () => {
|
140 | 139 | setJuegoTerminado(true);
|
141 | 140 | if (preguntasCorrectas + preguntasFalladas > 0) {
|
142 | 141 | const preguntasTotales=preguntasCorrectas+preguntasFalladas;
|
143 |
| - console.log(preguntasCorrectas); |
144 |
| - console.log(preguntasFalladas); |
145 | 142 | const tMedio=tiempoTotal/preguntasTotales;
|
146 | 143 | setTiempoMedio(tMedio);
|
147 |
| - console.log(tMedio); |
148 | 144 | }
|
149 | 145 | }
|
150 | 146 |
|
151 | 147 | };
|
152 | 148 |
|
153 | 149 | useEffect(() => {
|
154 |
| - if (juegoTerminado && tiempoMedio!=0) { |
| 150 | + if (juegoTerminado && tiempoMedio !== 0) { |
155 | 151 | guardarPartida();
|
156 | 152 | }
|
| 153 | + // eslint-disable-next-line |
157 | 154 | }, [juegoTerminado]);
|
158 | 155 |
|
159 | 156 | const guardarPartida = async () => {
|
@@ -202,7 +199,15 @@ const JuegoPreguntas = () => {
|
202 | 199 | return (
|
203 | 200 | <>
|
204 | 201 | <Nav />
|
205 |
| - <span class="loader"></span> |
| 202 | + <Spinner |
| 203 | + data-testid="spinner" |
| 204 | + thickness='4px' |
| 205 | + speed='0.65s' |
| 206 | + emptyColor='gray.200' |
| 207 | + color='teal.500' |
| 208 | + size='xl' |
| 209 | + margin='auto' |
| 210 | + /> |
206 | 211 | <Footer />
|
207 | 212 | </>
|
208 | 213 | );
|
@@ -255,9 +260,7 @@ const JuegoPreguntas = () => {
|
255 | 260 | <Button
|
256 | 261 | onClick={() => {
|
257 | 262 | const newTTotal=tiempoTotal+(SECS_PER_QUESTION-tiempoRestante);
|
258 |
| - console.log(newTTotal); |
259 | 263 | setTiempoTotal(newTTotal);
|
260 |
| - console.log(tiempoTotal); |
261 | 264 | setTiempoRestante(0)}}
|
262 | 265 | disabled={tiempoRestante === 0 || juegoTerminado}
|
263 | 266 | colorScheme="teal"
|
|
0 commit comments