empsearch modified

parent 88483e8a
...@@ -92,14 +92,21 @@ app.post("/getreportees",async (req, res) => { ...@@ -92,14 +92,21 @@ app.post("/getreportees",async (req, res) => {
let query = { empId: { $in: reporteesArray } }; let query = { empId: { $in: reporteesArray } };
let aggre = [{ $match: { empId: { $in: reporteesArray } } }]; let aggre = [{ $match: { empId: { $in: reporteesArray } } }];
aggre.push({
$addFields: {
empIdString: { $toString: "$empId" }
}
})
if (req.body.searchText) { if (req.body.searchText) {
let searchText = req.body.searchText.trim(); let searchText = req.body.searchText.trim();
let searchStr = new RegExp(searchText, "ig"); let searchStr = new RegExp(searchText, "ig");
let orCondation = { let orCondation = {
$or: [ $or: [
{ empId: searchStr }, { empIdString: searchStr },
{ empName: searchStr }, { empName: searchStr },
{ designation: searchStr }, { designation: searchStr },
{techStack:searchStr}
], ],
}; };
aggre.push({ $match: orCondation }); aggre.push({ $match: orCondation });
...@@ -120,7 +127,7 @@ app.post("/getreportees",async (req, res) => { ...@@ -120,7 +127,7 @@ app.post("/getreportees",async (req, res) => {
if (result && result.length) { if (result && result.length) {
res.status(201).json({ ...result[0] }); res.status(201).json({ ...result[0] });
} else { } else {
res.status(404).json({ data: [], totalCount: { count: 0 } }); res.status(201).json({ data: [], totalCount: { count: 0 } });
} }
}) })
.catch((error) => res.status(401).send(error)); .catch((error) => res.status(401).send(error));
......
...@@ -27,13 +27,7 @@ function Dashboard() { ...@@ -27,13 +27,7 @@ function Dashboard() {
setCurrPage(currPage) setCurrPage(currPage)
dispatch(fetchReportees(data)) dispatch(fetchReportees(data))
} }
// useEffect(() => {
// let data={
// reportees:reportees,
// ["page"]:page,
// }
// dispatch(fetchReportees(data))
// } ,[page]);
useEffect(() => { useEffect(() => {
setPagesCount(Math.ceil((totalCount) / (10))) setPagesCount(Math.ceil((totalCount) / (10)))
...@@ -95,15 +89,15 @@ function Dashboard() { ...@@ -95,15 +89,15 @@ function Dashboard() {
title: "Designation", title: "Designation",
id: 'designation' id: 'designation'
}, },
{
title: "Role",
id: 'techStack'
},
{ {
title: "score", title: "score",
id: "score", id: "score",
render: (value) => <span className={`w-[30px] h-[30px] rounded-full flex items-center text-white justify-center ${scoreColor(value)}`}>{value}</span> render: (value) => <span className={`w-[30px] h-[30px] rounded-full flex items-center text-white justify-center ${scoreColor(value)}`}>{value}</span>
}, },
{
title: "Role",
id: 'techStack'
},
{ {
title: "Action", title: "Action",
id: "empId", id: "empId",
...@@ -123,9 +117,8 @@ function Dashboard() { ...@@ -123,9 +117,8 @@ function Dashboard() {
<div className=""> <div className="">
{reportees && ( {reportees && (
<div className="flex justify-center mt-2"> <div className="flex justify-center mt-2 ">
{/* <div className="text-blue-500">Total Results: {pagesCount}</div> */} {pagesCount >= 1 && (
{pagesCount > 1 && (
<PaginationComponent <PaginationComponent
currentPage={currPage} currentPage={currPage}
totalPages={pagesCount} totalPages={pagesCount}
......
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