Commit 55777916 authored by Venkaiah Naidu Singamchetty's avatar Venkaiah Naidu Singamchetty

Merge branch 'apiserver' into 'master'

loginpage loading added'

See merge request !37
parents f98887e3 6ea669b2
import React, { useState } from "react";
import React, { useEffect, useState } from "react";
import { useNavigate } from "react-router-dom";
import axios from 'axios';
import { base_url } from "../../utils/constants";
import { loginUser } from "../../redux/reducers/userSlice";
import {useDispatch} from 'react-redux'
import Loading from '../../components/loading Component/Loading'
function Home() {
const navigate = useNavigate();
const dispatch=useDispatch()
const [id, setId] = useState(null);
const [errorMsg,setErrorMsg]=useState("")
const [loading,setLoading]=useState(true)
const handleNavigate = () => {
const handleNavigate = async () => {
setLoading(true)
if(id!==null){
axios.post(`${base_url}/login`,{empId:Number(id)})
await axios.post(`${base_url}/login`,{empId:Number(id)})
.then((res) => {
setLoading(false)
dispatch(loginUser(res.data.user))
navigate(`/dashboard`);
})
.catch((error)=>{
setLoading(false)
setErrorMsg("Not Authorized");
})
}else{
setLoading(false)
navigate(`/`);
}
};
useEffect(()=>{
setLoading(false)
},[])
if(loading) {return <Loading/>}
else
return (
<div className="container py-10 px-10 mx-0 min-w-full h-screen flex items-center justify-center bg-blue-100 ">
<div className="">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment