Commit 6ef0f74a authored by Venkaiah Naidu Singamchetty's avatar Venkaiah Naidu Singamchetty

Merge branch 'apiserver' into 'master'

network calls issues minimized

See merge request !42
parents 64a6b7d4 30a56a6d
...@@ -16,18 +16,18 @@ function Accordion({ title, data ,handleAddActivity,open,handleAccordian}) { ...@@ -16,18 +16,18 @@ function Accordion({ title, data ,handleAddActivity,open,handleAccordian}) {
const { reports,defaultAvgScore,initiativeAvgScore ,loading} = useSelector((state) => state.reports); const { reports,defaultAvgScore,initiativeAvgScore ,loading} = useSelector((state) => state.reports);
const userDetails = useSelector((state) => state.userDetails); const userDetails = useSelector((state) => state.userDetails);
//commented due to excess api calls by this method.
useEffect(()=>{ // useEffect(()=>{
if(userDetails.user!==null){ // if(userDetails.user!==null){
const data = { // const data = {
reportees: userDetails.user.reportees, // reportees: userDetails.user.reportees,
sort: { type: "empId", order: 1 }, // sort: { type: "empId", order: 1 },
page: 1, // page: 1,
perPage: 10, // perPage: 10,
} // }
dispatch(fetchReportees(data)) // dispatch(fetchReportees(data))
} // }
},[userDetails,id]) // },[userDetails,id])
useEffect(()=>{ useEffect(()=>{
if(reports !==null){ if(reports !==null){
......
...@@ -72,9 +72,10 @@ function Reports() { ...@@ -72,9 +72,10 @@ function Reports() {
"data": activityData "data": activityData
} }
await axios.post(`${base_url}/createActivity`, newData) await axios.post(`${base_url}/createActivity`, newData)
.then(async(result) => { .then(async (result) => {
await getReports() fetchLatestReporteesData()
await fetchLatestReporteesData() getReports()
}) })
} else { } else {
alert("Please login") alert("Please login")
...@@ -82,7 +83,7 @@ function Reports() { ...@@ -82,7 +83,7 @@ function Reports() {
} }
useEffect(() => { useEffect(() => {
if (id !== undefined || null) { if (id !== undefined || null && reportees.length>0) {
const emp = reportees?.filter((item) => item.empId === Number(id)); const emp = reportees?.filter((item) => item.empId === Number(id));
setEmpDetails(emp[0]); setEmpDetails(emp[0]);
const data = { const data = {
...@@ -103,11 +104,12 @@ function Reports() { ...@@ -103,11 +104,12 @@ function Reports() {
}else{ }else{
navigate("/") navigate("/")
} }
}, [user,id]); }, [id]);
return ( if(reportees.length && empDetails)
return (
<div className="p-4" > <div className="p-4" >
<div className=" bg-white p-3"> <div className="bg-white p-3">
<div className="flex"> <div className="flex">
{/* <img src="/generic-male-avatar-rectangular.jpg" width="100px" height="100px" /> */} {/* <img src="/generic-male-avatar-rectangular.jpg" width="100px" height="100px" /> */}
<div className="w-1/2"> <div className="w-1/2">
...@@ -147,8 +149,11 @@ function Reports() { ...@@ -147,8 +149,11 @@ function Reports() {
</div> </div>
</div> </div>
</div> </div>
); );
// } // else
return <div className="w-full h-full">
<p className="text-center align-middle mt-14 mb-14 text-blue-500">The Employee data you are trying to access <br/> is not under you reportees so data is hidden.</p>
</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