import {useState, useRef} from 'react' import {Link} from 'react-router-dom' import LandingIntro from './LandingIntro' import ErrorText from '../../components/Typography/ErrorText' import InputText from '../../components/Input/InputText' function Login(){ const INITIAL_LOGIN_OBJ = { password : "", emailId : "" } const [loading, setLoading] = useState(false) const [errorMessage, setErrorMessage] = useState("") const [loginObj, setLoginObj] = useState(INITIAL_LOGIN_OBJ) const submitForm = (e) =>{ e.preventDefault() setErrorMessage("") if(loginObj.emailId.trim() === "")return setErrorMessage("Email Id is required! (use any value)") if(loginObj.password.trim() === "")return setErrorMessage("Password is required! (use any value)") else{ setLoading(true) // Call API to check user credentials and save token in localstorage localStorage.setItem("token", "DumyTokenHere") setLoading(false) window.location.href = '/app/welcome' } } const updateFormValue = ({updateType, value}) => { setErrorMessage("") setLoginObj({...loginObj, [updateType] : value}) } return(