From 536c56ad713e98a90ddc53579d2a23cb44b4e157 Mon Sep 17 00:00:00 2001 From: CANCI0 Date: Sun, 10 Mar 2024 22:18:54 +0100 Subject: [PATCH] Warnings quitados --- webapp/src/components/Footer/Footer.js | 1 - webapp/src/components/Login/Login.js | 10 ++++------ webapp/src/pages/Authenticate/Authenticate.js | 3 --- webapp/src/pages/Stats/Stats.js | 1 - webapp/src/routers/ProtectedRoute.js | 2 +- 5 files changed, 5 insertions(+), 12 deletions(-) diff --git a/webapp/src/components/Footer/Footer.js b/webapp/src/components/Footer/Footer.js index 7198079f..0c26bd60 100644 --- a/webapp/src/components/Footer/Footer.js +++ b/webapp/src/components/Footer/Footer.js @@ -1,5 +1,4 @@ import React from 'react'; -import { Link } from "react-router-dom"; import './Footer.css'; const Footer = () => { diff --git a/webapp/src/components/Login/Login.js b/webapp/src/components/Login/Login.js index edd6f7e0..40122d62 100644 --- a/webapp/src/components/Login/Login.js +++ b/webapp/src/components/Login/Login.js @@ -1,7 +1,6 @@ // src/components/Login.js import React, { useState } from 'react'; import axios from 'axios'; -import { Container, Typography, TextField, Button, Snackbar } from '@mui/material'; import {useNavigate} from "react-router-dom"; import './Login.css'; @@ -9,10 +8,9 @@ import './Login.css'; const Login = () => { const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); - const [token, setToken] = useState(''); const [error, setError] = useState(''); const [loginSuccess, setLoginSuccess] = useState(false); - const [createdAt, setCreatedAt] = useState(''); + //const [createdAt, setCreatedAt] = useState(''); const [openSnackbar, setOpenSnackbar] = useState(false); const navigate = useNavigate(); @@ -23,10 +21,10 @@ const Login = () => { const response = await axios.post(`${apiEndpoint}/login`, { username, password }); console.log(response); // Extract data from the response - const { createdAt: userCreatedAt } = response.data; + //const { createdAt: userCreatedAt } = response.data; const { token: token } = response.data; - setCreatedAt(userCreatedAt); + //setCreatedAt(userCreatedAt); setLoginSuccess(true); setOpenSnackbar(true); @@ -36,7 +34,7 @@ const Login = () => { } catch (error) { //console.log(error); - //setError(error.response.data.error); + setError(error.response.data.error); } }; diff --git a/webapp/src/pages/Authenticate/Authenticate.js b/webapp/src/pages/Authenticate/Authenticate.js index 5ebf98de..6517775d 100644 --- a/webapp/src/pages/Authenticate/Authenticate.js +++ b/webapp/src/pages/Authenticate/Authenticate.js @@ -7,9 +7,6 @@ import Typography from '@mui/material/Typography'; import Link from '@mui/material/Link'; import Footer from '../../components/Footer/Footer.js'; -import { BrowserRouter as Router, Route, Redirect } from 'react-router-dom'; -import { PrivateRoute, useAuth } from 'react-auth-kit'; - function Authenticate() { const [showLogin, setShowLogin] = useState(true); diff --git a/webapp/src/pages/Stats/Stats.js b/webapp/src/pages/Stats/Stats.js index 682971b6..db4af029 100644 --- a/webapp/src/pages/Stats/Stats.js +++ b/webapp/src/pages/Stats/Stats.js @@ -1,5 +1,4 @@ import React, { useState, useEffect } from "react"; -import axios from "axios"; import Nav from "../../components/Nav/Nav.js"; import Footer from "../../components/Footer/Footer.js"; import "./Stats.css"; diff --git a/webapp/src/routers/ProtectedRoute.js b/webapp/src/routers/ProtectedRoute.js index db8b6dc7..735c69fe 100644 --- a/webapp/src/routers/ProtectedRoute.js +++ b/webapp/src/routers/ProtectedRoute.js @@ -2,7 +2,7 @@ import { Navigate, Outlet } from 'react-router-dom' export const ProtectedRoute = ({children, redirectTo= "/login"}) => { const token = localStorage.getItem('token'); - if(token == null || token == undefined){ + if(!token){ return } return children ? children :