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}) {
const { reports,defaultAvgScore,initiativeAvgScore ,loading} = useSelector((state) => state.reports);
const userDetails = useSelector((state) => state.userDetails);
useEffect(()=>{
if(userDetails.user!==null){
const data = {
reportees: userDetails.user.reportees,
sort: { type: "empId", order: 1 },
page: 1,
perPage: 10,
}
dispatch(fetchReportees(data))
}
},[userDetails,id])
//commented due to excess api calls by this method.
// useEffect(()=>{
// if(userDetails.user!==null){
// const data = {
// reportees: userDetails.user.reportees,
// sort: { type: "empId", order: 1 },
// page: 1,
// perPage: 10,
// }
// dispatch(fetchReportees(data))
// }
// },[userDetails,id])
useEffect(()=>{
if(reports !==null){
......
......@@ -72,9 +72,10 @@ function Reports() {
"data": activityData
}
await axios.post(`${base_url}/createActivity`, newData)
.then(async(result) => {
await getReports()
await fetchLatestReporteesData()
.then(async (result) => {
fetchLatestReporteesData()
getReports()
})
} else {
alert("Please login")
......@@ -82,7 +83,7 @@ function Reports() {
}
useEffect(() => {
if (id !== undefined || null) {
if (id !== undefined || null && reportees.length>0) {
const emp = reportees?.filter((item) => item.empId === Number(id));
setEmpDetails(emp[0]);
const data = {
......@@ -103,11 +104,12 @@ function Reports() {
}else{
navigate("/")
}
}, [user,id]);
}, [id]);
return (
if(reportees.length && empDetails)
return (
<div className="p-4" >
<div className=" bg-white p-3">
<div className="bg-white p-3">
<div className="flex">
{/* <img src="/generic-male-avatar-rectangular.jpg" width="100px" height="100px" /> */}
<div className="w-1/2">
......@@ -147,8 +149,11 @@ function Reports() {
</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