diff --git a/webapp/src/components/history/History.js b/webapp/src/components/history/History.js index d94dfaf6..137a7b05 100644 --- a/webapp/src/components/history/History.js +++ b/webapp/src/components/history/History.js @@ -34,7 +34,7 @@ export function History({darkMode}){ .catch(error => { //console.error('Error cargando el historial de todas las partidas del usuario:', error); }); - }, []); + }, [gamesEndpoint]);//<-cambiar el array de depencias error despliegue useEffect(() => { fetch(statisticsEndpoint) @@ -48,7 +48,7 @@ export function History({darkMode}){ .catch(error => { //console.error('Error cargando las estadísticas del usuario:', error); }); - }, []); + }, [statisticsEndpoint]);//<- cambiar el array de depencias error despliegue diff --git a/webapp/src/components/history/StatsBlock.jsx b/webapp/src/components/history/StatsBlock.jsx index 5741338b..5efeb24d 100644 --- a/webapp/src/components/history/StatsBlock.jsx +++ b/webapp/src/components/history/StatsBlock.jsx @@ -9,7 +9,7 @@ export function StatsBlock({ darkMode,playerStats }){ let hasHistory = true;//Por defecto lo pongo a true - if (!playerStats || !playerStats.nombreUsuario || playerStats.tiempoMedio == 0) { + if (!playerStats || !playerStats.nombreUsuario || playerStats.tiempoMedio === 0) { hasHistory = false; } diff --git a/webapp/src/components/logout/Logout.js b/webapp/src/components/logout/Logout.js index 47e5f2d6..ae74189a 100644 --- a/webapp/src/components/logout/Logout.js +++ b/webapp/src/components/logout/Logout.js @@ -12,7 +12,7 @@ const Logout = () => { useEffect(() => { logout(); - }, []); + }, [logout]); // Llamar a handleLogout cuando se monta el componente return ( diff --git a/webapp/src/components/rooms/JoinRoom.js b/webapp/src/components/rooms/JoinRoom.js index eef44f13..77874481 100644 --- a/webapp/src/components/rooms/JoinRoom.js +++ b/webapp/src/components/rooms/JoinRoom.js @@ -1,7 +1,6 @@ import React, { useState,useEffect } from 'react'; import { useNavigate } from 'react-router-dom'; -import { Box, Input, Button, Text, Tooltip, Icon, Center, VStack, HStack } from "@chakra-ui/react"; -import { InfoOutlineIcon } from '@chakra-ui/icons'; +import { Box, Input, Button, Text, Center, VStack } from "@chakra-ui/react"; import { useToast } from "@chakra-ui/react"; import socket from './socket'; import { useTranslation } from 'react-i18next'; @@ -11,7 +10,6 @@ const JoinRoomForm = () => { const [roomId, setRoomId] = useState(''); const [isLoading, setIsLoading] = useState(false); - const apiEndpoint = process.env.REACT_APP_API_URI ||'http://localhost:8000'; const username = localStorage.getItem('username'); const toast = useToast(); @@ -49,7 +47,7 @@ const JoinRoomForm = () => { socket.off('roomJoined'); socket.off('roomErrorJoining'); }; - }, []); + }, [navigate, toast]); const handleJoinRoom = async () => { diff --git a/webapp/src/components/rooms/RankingRoom.js b/webapp/src/components/rooms/RankingRoom.js index df0d7976..54291e36 100644 --- a/webapp/src/components/rooms/RankingRoom.js +++ b/webapp/src/components/rooms/RankingRoom.js @@ -1,6 +1,6 @@ import React from 'react'; import { useLocation } from 'react-router-dom'; -import { Box, Heading, Text, VStack, HStack, Badge } from "@chakra-ui/react"; +import { Heading, Text, VStack, HStack, Badge } from "@chakra-ui/react"; import { ChakraProvider } from '@chakra-ui/react'; function RankingRoom({darkMode}) { diff --git a/webapp/src/components/rooms/Room.js b/webapp/src/components/rooms/Room.js index 566a4271..0724736a 100644 --- a/webapp/src/components/rooms/Room.js +++ b/webapp/src/components/rooms/Room.js @@ -1,9 +1,7 @@ import React, { useState,useEffect,useRef } from 'react'; import { useParams } from 'react-router-dom'; import { useLocation } from 'react-router-dom'; -import { AlertDialog, AlertDialogBody, AlertDialogFooter, AlertDialogHeader, AlertDialogContent, AlertDialogOverlay, Button } from "@chakra-ui/react"; import { useNavigate } from 'react-router-dom'; -import Swal from 'sweetalert2'; import socket from './socket'; import Game from '../game/Game'; import { useTranslation } from 'react-i18next'; @@ -16,7 +14,6 @@ function Room({ darkMode }) { const isHost = location.state?.isHost; const [users, setUsers] = useState({}); - const [questions, setQuestions] = useState([]); const [gameStarted, setGameStarted] = useState(false); @@ -26,15 +23,9 @@ function Room({ darkMode }) { const {t, i18n} = useTranslation(); const [roomGame, setRoomGame] = useState(null); - //para el mensaje del ganador const [isOpen, setIsOpen] = useState(false); - const cancelRef = useRef(); - const onClose = () =>{ - setIsOpen(false); - navigate('/home'); - }; - + useEffect(() => { socket.on('currentUsers', (users) => { @@ -43,7 +34,7 @@ function Room({ darkMode }) { }); socket.emit('ready', { id: roomId }); - console.log("eres el host "+isHost); + //console.log("eres el host "+isHost); socket.on('gameStarted', (questionsServer) => { @@ -69,7 +60,7 @@ function Room({ darkMode }) { }); - }, [roomId]); + }, [roomId,users,navigate,winner]); //se encagr ad e que cuando las preguntas esten cargadas crees el modo de juego