empsearch modified

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