diff --git a/frontend/src/api/user.js b/frontend/src/api/user.js index ec3698e2..8dc1cc98 100644 --- a/frontend/src/api/user.js +++ b/frontend/src/api/user.js @@ -16,7 +16,6 @@ export const formatUserData = user => { export const getUser = async () => { try { - console.log('Getting current user...'); const res = await API.get(`users/@me/profile`); const user = formatUserData(res.data); return user; @@ -28,7 +27,6 @@ export const getUser = async () => { export const getUserById = async (id) => { try { - console.log('Getting user by username...'); const res = await API.get(`users/${id}/profile`); const user = formatUserData(res.data); diff --git a/frontend/src/components/Chat/tools/DisplayChatMessages.js b/frontend/src/components/Chat/tools/DisplayChatMessages.js index fb12b243..3c277f34 100644 --- a/frontend/src/components/Chat/tools/DisplayChatMessages.js +++ b/frontend/src/components/Chat/tools/DisplayChatMessages.js @@ -37,7 +37,6 @@ const DisplayChatMessages = ({ realConvo, userID, messagesEndRef, otherUser }) = navigate(`/tournaments/${tournamentID}`); registerForTournament(tournamentID); } catch (error) { - console.log(error); addNotification('error', error?.response?.data?.error || t('chat.invite.errorAccept')); } } @@ -48,7 +47,6 @@ const DisplayChatMessages = ({ realConvo, userID, messagesEndRef, otherUser }) = addNotification('success', t('chat.invite.inviteAccepted')); navigate('/game-challenge?inviteID=' + inviteID); } catch (error) { - console.log(error); addNotification('error', error?.response?.data?.error || t('chat.invite.errorAccept')); } } @@ -58,7 +56,6 @@ const DisplayChatMessages = ({ realConvo, userID, messagesEndRef, otherUser }) = await API.post(`/users/${challengerID}/challenge/${inviteID}/deny`); addNotification('success', t('chat.invite.inviteDeclined')); } catch (error) { - console.log(error); addNotification('error', error?.response?.data?.error || t('chat.invite.errorDecline')); } } @@ -71,7 +68,6 @@ const DisplayChatMessages = ({ realConvo, userID, messagesEndRef, otherUser }) = ); } else { let previousSenderID = null; - console.log(realConvo); return ( diff --git a/frontend/src/components/Game/Tournament/CreateTournament.js b/frontend/src/components/Game/Tournament/CreateTournament.js index 4e654670..19a254ac 100644 --- a/frontend/src/components/Game/Tournament/CreateTournament.js +++ b/frontend/src/components/Game/Tournament/CreateTournament.js @@ -33,8 +33,6 @@ const CreateTournament = ({ setOptions }) => { isPublic, maxParticipants }); - console.log('CreateTournament: tournament created'); - console.log('CreateTournament:', user.tournamentID); registerForTournament(response.data.tournamentID); navigate(`/tournaments/${response.data.tournamentID}`); } catch (error) { diff --git a/frontend/src/components/Game/Tournament/GameTournament.js b/frontend/src/components/Game/Tournament/GameTournament.js index f4e79874..4c24da9b 100644 --- a/frontend/src/components/Game/Tournament/GameTournament.js +++ b/frontend/src/components/Game/Tournament/GameTournament.js @@ -49,11 +49,9 @@ const GameTournament = () => { const { sendMessage, lastMessage, readyState } = useWebSocket(socketUrl, { onOpen: () => { - console.log("Match WebSocket connection opened"); reconnectAttempts.current = 0; }, onClose: (event) => { - console.log("Match WebSocket connection closed"); if (event.code === 1006 && !gameOver) handleReconnect(); }, shouldReconnect: () => !gameOver, @@ -64,9 +62,7 @@ const GameTournament = () => { const handleReconnect = useCallback(() => { if (reconnectAttempts.current < maxReconnectAttempts) { reconnectAttempts.current += 1; - console.log(`Attempting to reconnect... (Attempt ${reconnectAttempts.current})`); } else { - console.log('Max reconnection attempts reached. Redirecting to home.'); navigate('/'); } }, [navigate]); @@ -80,8 +76,6 @@ const GameTournament = () => { if (!resetMatch) return; const matchUrl = process.env.REACT_APP_ENV === 'production' ? '/ws/match' : 'ws://localhost:8000/ws/match'; - console.log('GameTournament.js: resetMatch', resetMatch); - setSocketUrl(`${matchUrl}?t=${Date.now()}`); currentMatchId.current = resetMatch.matchID; @@ -109,7 +103,6 @@ const GameTournament = () => { playerId.current = playerA.userID; setKey(prevKey => prevKey + 1); setResetMatch(null); - console.log('GameTournament.js: match resseted'); }, [resetMatch, setResetMatch]); @@ -210,8 +203,6 @@ const GameTournament = () => { const handler = handlers[data.e]; if (handler) { handler(); - } else { - console.log('GameTournament.js: Unhandled message:', data); } }, [lastMessage, sendMessage]); diff --git a/frontend/src/components/Game/Tournament/JoinTournament.js b/frontend/src/components/Game/Tournament/JoinTournament.js index 0d388928..d0a52e6e 100644 --- a/frontend/src/components/Game/Tournament/JoinTournament.js +++ b/frontend/src/components/Game/Tournament/JoinTournament.js @@ -41,7 +41,6 @@ const JoinTournament = () => { const fetchTournament = async () => { try { const response = await API.get(`/tournaments/${tournamentID}`); - console.log('JoinTournament.js: fetchTournament', response.data); updateTournament(response.data); } catch (error) { addNotification('error', error.response?.data?.error || 'Error fetching tournament data'); @@ -84,8 +83,7 @@ const JoinTournament = () => { const handleLeave = async () => { try { - const response = await API.delete(`/tournaments/@me`); - console.log('JoinTournament.js: handleLeave', response.data); + await API.delete(`/tournaments/@me`); } catch (error) { addNotification('error', error.response?.data?.error || 'Error leaving tournament'); } diff --git a/frontend/src/components/Game/remote/Game.js b/frontend/src/components/Game/remote/Game.js index 9772104d..9b138b50 100644 --- a/frontend/src/components/Game/remote/Game.js +++ b/frontend/src/components/Game/remote/Game.js @@ -43,9 +43,7 @@ const Game = () => { const handleReconnect = useCallback(() => { if (reconnectAttempts.current < maxReconnectAttempts) { reconnectAttempts.current += 1; - console.log(`Attempting to reconnect... (Attempt ${reconnectAttempts.current})`); } else { - console.log('Max reconnection attempts reached. Redirecting to home.'); navigate('/'); } }, [navigate]); @@ -152,7 +150,7 @@ const Game = () => { case 'PADDLE_RATE_LIMIT': // ignoring break; default: - console.log('Unhandled message:', data); + break; } } }, [lastMessage, gameState.player?.userID, handleHeartbeatAck, navigate]); diff --git a/frontend/src/components/Game/remote/Rewards.js b/frontend/src/components/Game/remote/Rewards.js index 957dc43b..1da87f52 100644 --- a/frontend/src/components/Game/remote/Rewards.js +++ b/frontend/src/components/Game/remote/Rewards.js @@ -11,8 +11,6 @@ const Rewards = ({ endGameData, isSpectator = false, isTournament }) => { const { user } = useAuth(); const { t } = useTranslation(); - console.log('Rewards.js:', endGameData); - return (

{t('game.gameOver')}

diff --git a/frontend/src/components/Navigation/ProfileDropdown.js b/frontend/src/components/Navigation/ProfileDropdown.js index b5b42579..42156e42 100644 --- a/frontend/src/components/Navigation/ProfileDropdown.js +++ b/frontend/src/components/Navigation/ProfileDropdown.js @@ -21,7 +21,6 @@ const ProfileDropdown = () => { try { if (user.tournamentID) { await API.delete(`/tournaments/@me`); - console.log('ProfileDropdown.js: successfully left tournament'); } setIsLoggedIn(false); setUser(null); diff --git a/frontend/src/components/Root/index.js b/frontend/src/components/Root/index.js index ebdad5e1..abe814b4 100644 --- a/frontend/src/components/Root/index.js +++ b/frontend/src/components/Root/index.js @@ -41,7 +41,6 @@ const Root = () => { useEffect(() => { if (!user?.tournamentID) return; - console.log('index.js:', user.tournamentID); const leaveTournament = async () => { try { @@ -53,7 +52,6 @@ const Root = () => { }; if (!location.pathname.includes(`/tournaments/${user.tournamentID}`)) { leaveTournament(); - console.log('index.js: leaving tournament'); } }, [location, user?.tournamentID, addNotification, setUser]); diff --git a/frontend/src/components/Settings/Privacy.js b/frontend/src/components/Settings/Privacy.js index 98573f13..b1103934 100644 --- a/frontend/src/components/Settings/Privacy.js +++ b/frontend/src/components/Settings/Privacy.js @@ -53,7 +53,6 @@ const Privacy = () => { link.click(); document.body.removeChild(link); window.URL.revokeObjectURL(blobUrl); - console.log('Data harvested'); setIsHarvesting(true); addNotification('success', t('settings.privacy.downloadingMessage')); }) diff --git a/frontend/src/components/Settings/Security/2FA/TwoFactorAuthSecurity.js b/frontend/src/components/Settings/Security/2FA/TwoFactorAuthSecurity.js index 4011dd8b..10bc6d74 100644 --- a/frontend/src/components/Settings/Security/2FA/TwoFactorAuthSecurity.js +++ b/frontend/src/components/Settings/Security/2FA/TwoFactorAuthSecurity.js @@ -9,7 +9,7 @@ import ErrorMessage from '../../../../styles/shared/ErrorMessage.styled'; import { useNotification } from '../../../../context/NotificationContext'; import { useTranslation } from 'react-i18next'; -const TwoFactorAuthSecurity = ({ formData, setUser, setShowTwoFactorAuth }) => { +const TwoFactorAuthSecurity = ({ formData, setUser, setShowTwoFactorAuth, setMainError }) => { const { addNotification } = useNotification(); const [availablePlatforms, setAvailablePlatforms] = useState([]); const [authCode, setAuthCode] = useState(''); @@ -44,17 +44,16 @@ const TwoFactorAuthSecurity = ({ formData, setUser, setShowTwoFactorAuth }) => { const submissionData = { ...formData }; - console.log('TwofactorAuthSecurity submissionData before:', submissionData); ['password', 'phone_number', 'email'].forEach(field => { if (!submissionData[field]) { delete submissionData[field]; } }); - console.log('TwofactorAuthSecurity submissionData after:', submissionData); API.patch('users/@me/profile', { ...submissionData, otp: authCode }) .then(() => { addNotification('success', t('settings.security.successMessage')); + setMainError(''); getUser() .then(res => { setUser(res); diff --git a/frontend/src/components/Settings/Security/Security.js b/frontend/src/components/Settings/Security/Security.js index 29a47d0c..c047db0f 100644 --- a/frontend/src/components/Settings/Security/Security.js +++ b/frontend/src/components/Settings/Security/Security.js @@ -150,6 +150,7 @@ const Security = ({ user, setUser }) => { formData={formData} setUser={setUser} setShowTwoFactorAuth={setShowTwoFactorAuth} + setMainError={setError} /> )} diff --git a/frontend/src/components/Settings/Security/TwoFactorAuthSecurity.js b/frontend/src/components/Settings/Security/TwoFactorAuthSecurity.js index 3242aee9..344c0408 100644 --- a/frontend/src/components/Settings/Security/TwoFactorAuthSecurity.js +++ b/frontend/src/components/Settings/Security/TwoFactorAuthSecurity.js @@ -27,11 +27,7 @@ const TwoFactorAuthSecurity = ({ formData, setUser, setSuccess, setShowTwoFactor const handlePlatform = (platform) => { API.post('auth/totp/request', { platform }) - .then(() => { - console.log('2FA: Request sent'); - }) .catch(err => { - console.log('2FA: Request failed'); setError(err.response.data.error); }); }; @@ -49,13 +45,11 @@ const TwoFactorAuthSecurity = ({ formData, setUser, setSuccess, setShowTwoFactor setDisableVerify(true); API.patch('users/@me/profile', { ...submissionData, otp: authCode }) - .then(res => { - console.log('2FA: Success'); + .then(() => { setSuccess(t('settings.security.successMessage')); getUser() .then(res => { setUser(res); - console.log('User data refetched and updated in context:', res.data); }) .catch(err => { setError(err.response.data.error); diff --git a/frontend/src/context/ChatContext.js b/frontend/src/context/ChatContext.js index 78e1570c..30d58d3b 100644 --- a/frontend/src/context/ChatContext.js +++ b/frontend/src/context/ChatContext.js @@ -54,8 +54,6 @@ export const ChatProvider = ({ children }) => { const sendMessage = useCallback(message => { if (socketChat.current && socketChat.current.readyState === WebSocket.OPEN) { socketChat.current.send(message); - } else { - console.log('WebSocket for Chat is not open'); } }, []); @@ -127,9 +125,7 @@ export const ChatProvider = ({ children }) => { socketChat.current = new WebSocket(WS_CHAT_URL + token); - socketChat.current.onopen = () => { - console.log('WebSocket for Chat connection opened') - }; + socketChat.current.onopen = () => {}; socketChat.current.onmessage = event => { const response = JSON.parse(event.data); @@ -211,8 +207,6 @@ export const ChatProvider = ({ children }) => { const newToken = await refreshToken(); if (newToken) { connectWSChat(); - } else { - console.log('Websocket for Chat failed to refresh the token'); } } }; @@ -223,7 +217,6 @@ export const ChatProvider = ({ children }) => { return () => { if (socketChat.current && socketChat.current.readyState === WebSocket.OPEN) { socketChat.current.close(); - console.log('WebSocket for Chat closed'); } }; }, [addNotification, setIsRefetch, navigate]); diff --git a/frontend/src/context/RelationContext.js b/frontend/src/context/RelationContext.js index c1b87162..cae341ba 100644 --- a/frontend/src/context/RelationContext.js +++ b/frontend/src/context/RelationContext.js @@ -67,9 +67,7 @@ const RelationProvider = ({ children }) => { socketStatus.current = new WebSocket(WS_STATUS_URL + token); - socketStatus.current.onopen = () => { - console.log('WebSocket for Status connection opened'); - }; + socketStatus.current.onopen = () => {}; socketStatus.current.onmessage = event => { const response = JSON.parse(event.data); @@ -92,8 +90,6 @@ const RelationProvider = ({ children }) => { const newToken = await refreshToken(); if (newToken) { connectWSStatus(); - } else { - console.log('Websocket for Status failed to refresh the token'); } } } @@ -104,7 +100,6 @@ const RelationProvider = ({ children }) => { return () => { if (socketStatus.current && socketStatus.current.readyState === WebSocket.OPEN) { socketStatus.current.close(); - console.log('WebSocket for Status closed'); } }; }, [setActivity]); diff --git a/frontend/src/context/TournamentContext.js b/frontend/src/context/TournamentContext.js index 8f8896ed..ccb2be44 100644 --- a/frontend/src/context/TournamentContext.js +++ b/frontend/src/context/TournamentContext.js @@ -27,8 +27,6 @@ const TournamentProvider = ({ children }) => { const sendMessage = useCallback((message) => { if (socketTournament.current && socketTournament.current.readyState === WebSocket.OPEN) { socketTournament.current.send(JSON.stringify(message)); - } else { - console.log('WebSocket for Tournaments is not open'); } }, []); @@ -107,8 +105,6 @@ const TournamentProvider = ({ children }) => { }).map(formatUserData), }); } - console.log('TournamentContext.js: updateTournament', data); - console.log('TournamentContext.js: isJoin', isJoin); }, [navigate, setUser]); useEffect(() => { @@ -138,7 +134,6 @@ const TournamentProvider = ({ children }) => { socketTournament.current = new WebSocket(WS_TOURNAMENT_URL); socketTournament.current.onopen = () => { - console.log('WebSocket for Tournament connection opened'); identify(); }; @@ -162,7 +157,6 @@ const TournamentProvider = ({ children }) => { updateTournament(data.d, false); break; case 'TOURNAMENT_MATCH_BEGIN': - console.log('TournamentContext.js: upcoming matches', data.d.matches); setTimeout(() => { setResetMatch(data.d); }, 3000); @@ -181,7 +175,7 @@ const TournamentProvider = ({ children }) => { navigate(`/tournaments/${data.d.tournamentID}/results`); break; default: - console.log('TournamentContext.js: Unhandled event:', data.e); + break; } }; @@ -195,8 +189,6 @@ const TournamentProvider = ({ children }) => { if (newToken) { connectWSTournament(); addNotification('info', tRef.current('game.tournaments.reconnectMessage')); - } else { - console.log('WebSocket for Tournaments failed to refresh the token'); } } }; @@ -208,7 +200,6 @@ const TournamentProvider = ({ children }) => { if (heartbeatIntervalRef.current) clearInterval(heartbeatIntervalRef.current); if (socketTournament.current && socketTournament.current.readyState === WebSocket.OPEN) { socketTournament.current.close(); - console.log('WebSocket for Tournaments closed'); } }; }, [identify, heartbeat, navigate, updateTournament, addNotification]);