Skip to content

Commit

Permalink
Warnings quitados
Browse files Browse the repository at this point in the history
  • Loading branch information
CANCI0 committed Mar 10, 2024
1 parent 07d66b0 commit 536c56a
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 12 deletions.
1 change: 0 additions & 1 deletion webapp/src/components/Footer/Footer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { Link } from "react-router-dom";
import './Footer.css';

const Footer = () => {
Expand Down
10 changes: 4 additions & 6 deletions webapp/src/components/Login/Login.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
// 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';


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();

Expand All @@ -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);
Expand All @@ -36,7 +34,7 @@ const Login = () => {

} catch (error) {
//console.log(error);
//setError(error.response.data.error);
setError(error.response.data.error);
}
};

Expand Down
3 changes: 0 additions & 3 deletions webapp/src/pages/Authenticate/Authenticate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 0 additions & 1 deletion webapp/src/pages/Stats/Stats.js
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/routers/ProtectedRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Navigate to={redirectTo}/>
}
return children ? children : <Outlet />
Expand Down

0 comments on commit 536c56a

Please sign in to comment.