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

Merge branch 'apiserver' into 'master'

recalling modified

See merge request !87
parents 07644bf7 60956ff6
...@@ -13,7 +13,7 @@ function Dashboard() { ...@@ -13,7 +13,7 @@ function Dashboard() {
const { reportees, loading, totalCount, currPage, pagesCount} = useSelector((state) => state.reportees); const { reportees, loading, totalCount, currPage, pagesCount} = useSelector((state) => state.reportees);
const userDetails = useSelector((state) => state.userDetails); const userDetails = useSelector((state) => state.userDetails);
const [reporteIds, setReporteIds] = useState([]); const [reporteIds, setReporteIds] = useState([]);
const [inputValue, setInputValue] = useState(''); const [inputValue, setInputValue] = useState(null);
// userDetails.user.reportees || []; // userDetails.user.reportees || [];
const handlePageChange = (currPage) => { const handlePageChange = (currPage) => {
...@@ -31,11 +31,11 @@ function Dashboard() { ...@@ -31,11 +31,11 @@ function Dashboard() {
dispatch(setPagesCount(Math.ceil((totalCount) / (10)))) dispatch(setPagesCount(Math.ceil((totalCount) / (10))))
}, [totalCount]) }, [totalCount])
useEffect(() => { useEffect(() => {
if (reporteIds.length > 0) { if (reporteIds.length > 0 ) {
const data = { const data = {
reportees: userDetails.user.reportees, reportees: userDetails.user.reportees,
// sort: { type: "empId", order: 1 },
page: currPage, page: currPage,
perPage: 10 perPage: 10
}; };
...@@ -53,6 +53,7 @@ function Dashboard() { ...@@ -53,6 +53,7 @@ function Dashboard() {
}, [userDetails]); }, [userDetails]);
useEffect(() => { useEffect(() => {
if(inputValue!==null){
const debounceTimeout = setTimeout(() => { const debounceTimeout = setTimeout(() => {
const data = { const data = {
reportees: userDetails.user.reportees, reportees: userDetails.user.reportees,
...@@ -62,8 +63,10 @@ function Dashboard() { ...@@ -62,8 +63,10 @@ function Dashboard() {
}; };
dispatch(fetchReportees(data)); dispatch(fetchReportees(data));
}, 1000); }, 1000);
return () => clearTimeout(debounceTimeout); return () => clearTimeout(debounceTimeout);
}
// return () => clearTimeout(debounceTimeout);
}, [inputValue]); }, [inputValue]);
const handleChange = (event) => { const handleChange = (event) => {
...@@ -122,7 +125,7 @@ function Dashboard() { ...@@ -122,7 +125,7 @@ function Dashboard() {
<Table headers={headers} data={reportees} loading={loading} maxHeight={88} /> <Table headers={headers} data={reportees} loading={loading} maxHeight={88} />
<div className=""> <div className="">
{reportees && ( {reportees.length>0 && (
<div className="flex justify-center mt-2"> <div className="flex justify-center mt-2">
{/* <div className="text-blue-500">Total Results: {pagesCount}</div> */} {/* <div className="text-blue-500">Total Results: {pagesCount}</div> */}
{pagesCount >= 1 && ( {pagesCount >= 1 && (
......
...@@ -12,19 +12,12 @@ import {scoreColor} from '../../utils/commonFunctions'; ...@@ -12,19 +12,12 @@ import {scoreColor} from '../../utils/commonFunctions';
function Viewreportee() { function Viewreportee() {
const dispatch = useDispatch(); const dispatch = useDispatch();
const navigate = useNavigate(); const navigate = useNavigate();
const {reportees, viewReportee } = useSelector((state) => state.reportees); const {reportees, viewReportee,currPage } = useSelector((state) => state.reportees);
const user = useSelector((state) => state.userDetails.user) const user = useSelector((state) => state.userDetails.user)
const { reports, loading, error, dutiesReports, initiativeReports } = useSelector((state) => state.reports); const { reports, loading, error, dutiesReports, initiativeReports } = useSelector((state) => state.reports);
const [open, setOpen] = useState({ "accordianOne": false, "accordianTwo": false }); const [open, setOpen] = useState({ "accordianOne": false, "accordianTwo": false });
/*Example post data
{
"empId":41689,
"fromDate":"2024-03-10",
"toDate":"2024-03-11"
}
*/
const fetchActivities = (type) => { const fetchActivities = (type) => {
const data ={ const data ={
empId:viewReportee?.empId, empId:viewReportee?.empId,
...@@ -54,7 +47,7 @@ function Viewreportee() { ...@@ -54,7 +47,7 @@ function Viewreportee() {
if (user) { if (user) {
const data = { const data = {
reportees: user.reportees, reportees: user.reportees,
page: 1, page: currPage,
perPage: 10, perPage: 10,
}; };
dispatch(fetchReportees(data)) dispatch(fetchReportees(data))
...@@ -79,15 +72,15 @@ function Viewreportee() { ...@@ -79,15 +72,15 @@ function Viewreportee() {
} }
useEffect(()=>{ useEffect(()=>{
if(reportees.length>0 && viewReportee !== null) if(reportees.length>0 && viewReportee !== null )
dispatch(fetchActivitiesAvg({empId:viewReportee?.empId, types:["duties", "initiative"]})) dispatch(fetchActivitiesAvg({empId:viewReportee?.empId, types:["duties", "initiative"]}))
},[viewReportee]) },[reportees,viewReportee])
useEffect(()=>{ useEffect(()=>{
if(reportees.length){ if(reportees.length>0 && viewReportee !== null){
dispatch(setViewReportee(viewReportee?.empId)) dispatch(setViewReportee(viewReportee?.empId))
} }
},[reportees]) },[reportees,viewReportee])
...@@ -100,12 +93,11 @@ function Viewreportee() { ...@@ -100,12 +93,11 @@ function Viewreportee() {
} }
}, []); }, []);
if ( reportees.length && viewReportee) if ( reportees.length && viewReportee!==null)
return ( return (
<div className="p-4" > <div className="p-4" >
<div className="bg-white p-3 rounded-md"> <div className="bg-white p-3 rounded-md">
<div className="flex justify-between"> <div className="flex justify-between">
{/* <img src="/generic-male-avatar-rectangular.jpg" width="100px" height="100px" /> */}
<div className="my-1"> <div className="my-1">
<p> <p>
<span className="font-medium">Employee Name : </span> {viewReportee?.empName} <span className="font-medium">Employee Name : </span> {viewReportee?.empName}
...@@ -113,9 +105,6 @@ function Viewreportee() { ...@@ -113,9 +105,6 @@ function Viewreportee() {
<p> <p>
<span className="font-medium">Designation : </span> {viewReportee?.designation} <span className="font-medium">Designation : </span> {viewReportee?.designation}
</p> </p>
{/* <p>
<span className="font-medium">Email Id: </span> {viewReportee?.empEmail}
</p> */}
</div> </div>
<div className="my-1"> <div className="my-1">
<p> <p>
...@@ -124,13 +113,6 @@ function Viewreportee() { ...@@ -124,13 +113,6 @@ function Viewreportee() {
<p> <p>
<span className="font-medium">Employee Id: </span> {viewReportee?.empId} <span className="font-medium">Employee Id: </span> {viewReportee?.empId}
</p> </p>
{/* <p>
<span className="font-medium">Total Score : </span> {viewReportee?.score}
</p> */}
{/* <p>
<span className="font-medium">Allocated To : </span> {viewReportee?.project}
</p> */}
</div> </div>
<div className="flex flex-col justify-center items-center"> <div className="flex flex-col justify-center items-center">
<div className={`w-[40px] h-[40px] rounded-full flex items-center text-white justify-center ${scoreColor(viewReportee?.score)}`}> <div className={`w-[40px] h-[40px] rounded-full flex items-center text-white justify-center ${scoreColor(viewReportee?.score)}`}>
...@@ -140,7 +122,6 @@ function Viewreportee() { ...@@ -140,7 +122,6 @@ function Viewreportee() {
<span className="text-blue-400 font-semibold">Total Score</span> <span className="text-blue-400 font-semibold">Total Score</span>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div className=""> <div className="">
......
...@@ -29,7 +29,7 @@ const reporteesSlice = createSlice({ ...@@ -29,7 +29,7 @@ const reporteesSlice = createSlice({
if(!reportee){ if(!reportee){
return { return {
...state, ...state,
viewReportee: null viewReportee: state.viewReportee
} }
} else { } else {
return { return {
......
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