Skip to content

Commit

Permalink
Ahora el login redirige a /home
Browse files Browse the repository at this point in the history
  • Loading branch information
CANCI0 committed Mar 5, 2024
1 parent 8451c0b commit 8e35c02
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions webapp/src/components/Login/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import React, { useState } from 'react';
import axios from 'axios';
import { Container, Typography, TextField, Button, Snackbar } from '@mui/material';
import {Navigate, useNavigate} from "react-router-dom";

const Login = () => {
const [username, setUsername] = useState('');
Expand All @@ -10,6 +11,7 @@ const Login = () => {
const [loginSuccess, setLoginSuccess] = useState(false);
const [createdAt, setCreatedAt] = useState('');
const [openSnackbar, setOpenSnackbar] = useState(false);
const navigate = useNavigate();

const apiEndpoint = process.env.REACT_APP_API_ENDPOINT || 'http://localhost:8000';

Expand Down Expand Up @@ -40,14 +42,7 @@ const Login = () => {
return (
<Container component="main" maxWidth="xs" sx={{ marginTop: 4 }}>
{loginSuccess ? (
<div>
<Typography component="h1" variant="h5" sx={{ textAlign: 'center' }}>
Hello {username}!
</Typography>
<Typography component="p" variant="body1" sx={{ textAlign: 'center', marginTop: 2 }}>
Your account was created on {new Date(createdAt).toLocaleDateString()}.
</Typography>
</div>
navigate("/home")
) : (
<div>
<Typography component="h1" variant="h5">
Expand Down

0 comments on commit 8e35c02

Please sign in to comment.