Commit 4ac4b136 authored by Venkaiah Naidu Singamchetty's avatar Venkaiah Naidu Singamchetty

Merge branch 'initailSetup' into 'master'

added autoFocus

See merge request !62
parents 4c4ebe82 3c650f35
...@@ -76,7 +76,6 @@ function Dashboard() { ...@@ -76,7 +76,6 @@ function Dashboard() {
{ {
title: "Employee Name", title: "Employee Name",
id: "empName", id: "empName",
renderHeader: (value) => <div><span>{value}</span> <input placeholder="Search Employee" value={inputValue} onChange={handleChange} type="text" className="p-2 mi-2 border rounded"/></div>,
render: (value) => <span className="flex items-center"> render: (value) => <span className="flex items-center">
{/* <img className="pr-2" src="/man.png" width="30px" height="30px" /> */} {/* <img className="pr-2" src="/man.png" width="30px" height="30px" /> */}
{value}</span> {value}</span>
...@@ -113,6 +112,10 @@ function Dashboard() { ...@@ -113,6 +112,10 @@ function Dashboard() {
return ( return (
<div> <div>
<div className="mb-2"> <div className="mb-2">
<div className="flex justify-end my-1 mr-2 items-center">
<label>Search Employee:</label>
<input placeholder="Enter value" value={inputValue} onChange={handleChange} type="text" className="p-1 px-2 border rounded ml-2"/>
</div>
<Table headers={headers} data={reportees} loading={loading} maxHeight={88} /> <Table headers={headers} data={reportees} loading={loading} maxHeight={88} />
<div className=""> <div className="">
......
import React, { useEffect, useState } from "react"; import React, { useEffect, useState, useRef } from "react";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import axios from 'axios'; import axios from 'axios';
import { base_url } from "../../utils/constants"; import { base_url } from "../../utils/constants";
...@@ -7,6 +7,7 @@ import {useDispatch,useSelector} from 'react-redux' ...@@ -7,6 +7,7 @@ import {useDispatch,useSelector} from 'react-redux'
import Loading from '../../components/loading Component/Loading' import Loading from '../../components/loading Component/Loading'
function Home() { function Home() {
const inputRef = useRef(null);
const navigate = useNavigate(); const navigate = useNavigate();
const dispatch=useDispatch() const dispatch=useDispatch()
const [id, setId] = useState(null); const [id, setId] = useState(null);
...@@ -15,10 +16,11 @@ function Home() { ...@@ -15,10 +16,11 @@ function Home() {
const userDetails = useSelector((state) => state.userDetails); const userDetails = useSelector((state) => state.userDetails);
const handleNavigate = async () => { const handleSubmit = async (e) => {
e.preventDefault();
setLoading(true) setLoading(true)
if(id!==null){ if(id!==null){
await axios.post(`${base_url}/login`,{empId:Number(id)}) await axios.post(`${base_url}/login`,{empId:Number(inputRef.current.value)})
.then((res) => { .then((res) => {
setLoading(false) setLoading(false)
dispatch(loginUser(res.data.user)) dispatch(loginUser(res.data.user))
...@@ -35,6 +37,7 @@ function Home() { ...@@ -35,6 +37,7 @@ function Home() {
}; };
useEffect(()=>{ useEffect(()=>{
setLoading(false) setLoading(false)
inputRef.current.focus();
},[]) },[])
useEffect(()=>{ useEffect(()=>{
if (userDetails?.user!=null) if (userDetails?.user!=null)
...@@ -47,8 +50,7 @@ function Home() { ...@@ -47,8 +50,7 @@ function Home() {
<div className="container py-10 px-10 mx-0 min-w-full h-screen flex items-center justify-center bg-blue-100 "> <div className="container py-10 px-10 mx-0 min-w-full h-screen flex items-center justify-center bg-blue-100 ">
<div className=""> <div className="">
<h1 className="text-4xl font-extrabold leading-none tracking-tight md:text-5xl lg:text-6xl text-purple-900 mb-10 ">SCORE CARD</h1> <h1 className="text-4xl font-extrabold leading-none tracking-tight md:text-5xl lg:text-6xl text-purple-900 mb-10 ">SCORE CARD</h1>
{/* { <form>
(loading)?<Loading/>: */}
<div className="max-w-sm p-10 bg-white border border-gray-400 rounded-lg shadow "> <div className="max-w-sm p-10 bg-white border border-gray-400 rounded-lg shadow ">
<label <label
htmlFor="email" htmlFor="email"
...@@ -63,6 +65,7 @@ function Home() { ...@@ -63,6 +65,7 @@ function Home() {
placeholder="Enter Employee ID" placeholder="Enter Employee ID"
required required
onChange={(e) => setId(e.target.value)} onChange={(e) => setId(e.target.value)}
ref={inputRef}
/> />
{ {
...@@ -75,17 +78,21 @@ function Home() { ...@@ -75,17 +78,21 @@ function Home() {
<div className="flex justify-between"> <div className="flex justify-between">
<button <button
className="bg-purple-900 text-white disabled:bg-purple-900 hover:bg-blue-400 font-bold py-2 px-4 mt-6 rounded text-center" className="bg-purple-900 text-white disabled:bg-purple-900 hover:bg-blue-400 font-bold py-2 px-4 mt-6 rounded text-center"
onClick={handleNavigate} onClick={(e) => handleSubmit(e)}
disabled={!id} disabled={!id}
type="submit"
> >
Submit Submit
</button> </button>
{ {
(loading)?<img src="/Loader2.gif" className="" width={100} height={100}/>:null (loading)?<img src="/Loader2.gif" className="" width={100} height={100}/>:null
} }
</div> </div>
</div> </div>
{/* } */} </form>
</div> </div>
</div> </div>
); );
......
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