diff --git a/web-ui/web-react/src/components/LogIn.js b/web-ui/web-react/src/components/LogIn.js index 8777a82f..b70037de 100644 --- a/web-ui/web-react/src/components/LogIn.js +++ b/web-ui/web-react/src/components/LogIn.js @@ -1,45 +1,219 @@ -import React, { useState } from 'react'; +import React, { Component, Fragment, useRef } from 'react'; +import Cookies from 'universal-cookie'; import { InputText } from 'primereact/inputtext'; +import { Button } from 'primereact/button'; -const LogIn = () => { +const baseUrl = "http://localhost:4000/user/loginUser"; +const cookies = new Cookies(); - const [email, setEmail] = useState(""); - const [password, setPassword] = useState(""); +class Login extends Component { + constructor(props) { + super(props); + this.state = { + form: { + email: '', + password: '' + }, + errorEmail: false, + errorPassword: false, + logged: null + } + } + handleChange = async e => { + await this.setState({ + form: { + ...this.state.form, + [e.target.name]: e.target.value + } + }); + } - const iniciarSesion = () =>{ + validaciones = (data) => { + let error = true; + if (data.email == '') { + this.setState({ + errorEmail: true + }) + error = true; + } else { + this.setState({ + errorEmail: false + }) + } + if (data.password == '') { + this.setState({ + errorPassword: true + }) + error = true; + } else { + this.setState({ + errorPassword: false + }) + } + + return error; } - + iniciarSesion = async () => { + const data = { + email: this.state.form.email, + password: this.state.form.password + } - return ( -