From 3240756ddef2a5c73ca4f78081a9ab43009e7707 Mon Sep 17 00:00:00 2001 From: Roberto Date: Mon, 6 May 2024 07:39:34 -0600 Subject: [PATCH] cambios en login y principal --- healthmanager/src/Login.css | 1 + healthmanager/src/Login.jsx | 11 +- healthmanager/src/Principal.css | 59 +++++++++ healthmanager/src/Principal.jsx | 93 +++++++++++++++ healthmanager/src/assets/logohm (1).svg | 152 ++++++++++++++++++++++++ healthmanager/src/main.jsx | 5 +- 6 files changed, 314 insertions(+), 7 deletions(-) create mode 100644 healthmanager/src/assets/logohm (1).svg diff --git a/healthmanager/src/Login.css b/healthmanager/src/Login.css index 8ae9797..75339e6 100644 --- a/healthmanager/src/Login.css +++ b/healthmanager/src/Login.css @@ -34,5 +34,6 @@ form { padding-top: 20px; height: 400px; border-radius: 10px; + box-shadow: 8px 8px 8px gray; background-color: whitesmoke; } diff --git a/healthmanager/src/Login.jsx b/healthmanager/src/Login.jsx index eaa5c39..3f2de70 100644 --- a/healthmanager/src/Login.jsx +++ b/healthmanager/src/Login.jsx @@ -10,6 +10,7 @@ function Login(props) { const [Cargando, setCargando] = useState (false) const [datosLogin, setDatosLogin] = useState( {correo:'', contraseña:''} ) + // eslint-disable-next-line no-unused-vars const hacerPeticion = async () => { // eslint-disable-next-line no-useless-catch try { @@ -32,14 +33,14 @@ function Login(props) { console.log("datos recuperados en el form: ", datosLogin) setCargando(true) try { - const response = await hacerPeticion() + //const response = await hacerPeticion() setCargando(false) - if (response.data === 'Usuario Correcto') { + //if (response.data === 'Usuario Correcto') { navigate('/Principal'); window.localStorage.setItem('Usuario',datosLogin.correo); - } else { - alert("Credenciales incorrectas, revisa tu correo o contraseña"); - } + //} else { + //alert("Credenciales incorrectas, revisa tu correo o contraseña"); + //} } catch (error) { console.log("error", error) setCargando(false) diff --git a/healthmanager/src/Principal.css b/healthmanager/src/Principal.css index e69de29..a346c6e 100644 --- a/healthmanager/src/Principal.css +++ b/healthmanager/src/Principal.css @@ -0,0 +1,59 @@ +h1 { + text-align: center; + font-family: Arial, Helvetica, sans-serif; + } +body{ + background-color: aliceblue; + background-image: none; +} + #bienvenidoUsuario { + text-align: center; + font-size: medium; + font-family: Arial, Helvetica, sans-serif; + } + #headerFacultad{ + margin-left: 50px; + text-align: left; + font-family: Arial, Helvetica, sans-serif; + } + #headerPublicaciones{ + margin-left: 120px; + } + #divPublicaciones{ + display: flex; + height: max-content; + } + #divsPublicaciones{ + width: 600px; + text-align:justify; + font-family:Georgia, 'Times New Roman', Times, serif; + } + #boxCerrar{ + padding-top: 20px; + margin-left: auto; + margin-right: 100px; + } + #divLista{ + width: max-content; + display:grid; + padding: 180px; + } + #headerForm { + font-size: small; + } + #divBotones{ + display:flex; + justify-content: center; + align-items: center; + } + #botonMiPerfil,#botonMisPublicaciones,#botonNuevaPublicacion{ + width: 300px; + height: 300px; + margin: 20px; + } + #divMenu { + font-family:Arial, Helvetica, sans-serif; + margin-left: auto; + margin-right: 150px; + padding: 10px; + } \ No newline at end of file diff --git a/healthmanager/src/Principal.jsx b/healthmanager/src/Principal.jsx index e69de29..720a5de 100644 --- a/healthmanager/src/Principal.jsx +++ b/healthmanager/src/Principal.jsx @@ -0,0 +1,93 @@ +/* eslint-disable no-unused-vars */ +import { Button, Box, TextField, DialogContentText, Divider } from "@mui/material" +import axios from "axios" +import {useEffect,useState } from "react" +import './Principal.css' +import { useNavigate } from 'react-router-dom' +function Principal(props) { + const navigate = useNavigate(); + const [publicacionesData, setPublicacionesData] = useState([]); + // eslint-disable-next-line no-unused-vars + const [Cargando, setCargando] = useState (false) + const correoUsuario = window.localStorage.getItem('Usuario'); + + const datosUsuario=async()=>{ + try { + const respuesta=await axios.get("https://back-endproyectofinal8-production-a397.up.railway.app/datosUsuario",{params:{correo: correoUsuario}}); + return respuesta.data; + } catch (error) { + console.log(error); + } + } + + const UsuarioData=async()=>{ + try { + const respuesta=await datosUsuario(); + const nombreUsuarioSesion=respuesta.idUsuario; + const contraseñaUsuarioSesion=respuesta.contraseña; + window.localStorage.setItem("ID",nombreUsuarioSesion); + window.localStorage.setItem("Contraseña",contraseñaUsuarioSesion); + } catch (error) { + console.log("holaa"); + console.log(error); + } + } + UsuarioData(); + + const cerrarSesion = () => { + navigate('/'); + } + + const miPerfil = () => { + navigate('/MiPerfil'); + } + + const publicaciones = () => { + navigate('/Publicaciones') + } + + const crearPublicacion = () => { + navigate('/CrearPublicacion'); + } + + useEffect(() => { + const fetchData = async () => { + // eslint-disable-next-line no-useless-catch + try { + const res = await axios.get("https://back-endproyectofinal8-production-a397.up.railway.app/Publicaciones"); + console.log("Publicaciones data: ",res.data); + setPublicacionesData(res.data); + } catch (error) { + throw error; + } + }; + fetchData(); + }, []); + + const usuarioSesion = window.localStorage.getItem('ID'); + + return ( + + <> +
+

Health Manager

+ +
+

Menu Principal

+

¡Hola {usuarioSesion}!

+ + + +
+ +
+ + + +
+
+ + ) +} + +export default Principal \ No newline at end of file diff --git a/healthmanager/src/assets/logohm (1).svg b/healthmanager/src/assets/logohm (1).svg new file mode 100644 index 0000000..2df4712 --- /dev/null +++ b/healthmanager/src/assets/logohm (1).svg @@ -0,0 +1,152 @@ + + + + +Created by potrace 1.16, written by Peter Selinger 2001-2019 + + + + + + + + + diff --git a/healthmanager/src/main.jsx b/healthmanager/src/main.jsx index c745198..058eed6 100644 --- a/healthmanager/src/main.jsx +++ b/healthmanager/src/main.jsx @@ -2,7 +2,7 @@ import React from 'react' import ReactDOM from 'react-dom/client' import Login from './Login.jsx' import { RouterProvider, createHashRouter } from 'react-router-dom' -//import Principal from './Principal.jsx' +import Principal from './Principal.jsx' //import Registro from './Registro.jsx' //import MiPerfil from './MiPerfil.jsx' //import Publicaciones from './Publicaciones' @@ -16,10 +16,11 @@ import { RouterProvider, createHashRouter } from 'react-router-dom' path: "/Registro", element: }, + */ { path: "/Principal", element: - }, + }/*, { path: "/Publicaciones", element: