Skip to content

Commit 43bded4

Browse files
Merge pull request #377 from IshikaSoni056/hire
candidates page
2 parents 2dcd63a + 32e758d commit 43bded4

File tree

3 files changed

+173
-58
lines changed
  • jobsdoor360-website/src/main/ejs/main-files/myaccount/hire/candidates
  • myaccount/hire/candidates
  • staticfiles/mainfiles/myaccount/hire/candidates

3 files changed

+173
-58
lines changed

jobsdoor360-website/src/main/ejs/main-files/myaccount/hire/candidates/index.ejs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,31 @@
8585
8686
*/
8787
88+
#globalSearch {
89+
padding: 8px 12px;
90+
font-size: 16px;
91+
border: 1px solid #ccc;
92+
/* border-radius: 6px; */
93+
width: 250px;
94+
}
95+
96+
#globalSearchBtn {
97+
background-color: #28a745;
98+
color: white;
99+
border: none;
100+
padding: 8px 16px;
101+
font-size: 16px;
102+
margin-left: 10px;
103+
/* border-radius: 6px; */
104+
cursor: pointer;
105+
transition: background 0.3s ease;
106+
}
107+
108+
#globalSearchBtn:hover {
109+
background-color: #218838;
110+
}
111+
112+
88113
89114
</style>
90115

@@ -139,6 +164,12 @@
139164
My Company
140165
</label>
141166
</div> -->
167+
168+
<input type="text" id="globalSearch" placeholder="Search all fields..." />
169+
<button type="button" id="globalSearchBtn" onclick="handleGlobalSearch()">Search All Fields</button>
170+
171+
172+
142173
</div>
143174
<!-- User profiles table -->
144175

myaccount/hire/candidates/index.html

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,31 @@
9696
9797
*/
9898

99+
#globalSearch {
100+
padding: 8px 12px;
101+
font-size: 16px;
102+
border: 1px solid #ccc;
103+
/* border-radius: 6px; */
104+
width: 250px;
105+
}
106+
107+
#globalSearchBtn {
108+
background-color: #28a745;
109+
color: white;
110+
border: none;
111+
padding: 8px 16px;
112+
font-size: 16px;
113+
margin-left: 10px;
114+
/* border-radius: 6px; */
115+
cursor: pointer;
116+
transition: background 0.3s ease;
117+
}
118+
119+
#globalSearchBtn:hover {
120+
background-color: #218838;
121+
}
122+
123+
99124

100125
</style>
101126

@@ -313,6 +338,12 @@
313338
My Company
314339
</label>
315340
</div> -->
341+
342+
<input type="text" id="globalSearch" placeholder="Search all fields..." />
343+
<button type="button" id="globalSearchBtn" onclick="handleGlobalSearch()">Search All Fields</button>
344+
345+
346+
316347
</div>
317348
<!-- User profiles table -->
318349

staticfiles/mainfiles/myaccount/hire/candidates/script.js

Lines changed: 111 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -85,49 +85,49 @@ document.addEventListener("DOMContentLoaded", async function () {
8585

8686
//Function to add consultancy feedback (stored as an array)
8787

88-
async function addConsultancyRemark(email, remark, date) {
89-
if (!email || !remark || !date) {
90-
alert("Please enter a remark and select a valid date.");
91-
return;
92-
}
93-
94-
try {
95-
const userRef = doc(db, "user_consultancies", email); // Use email as document ID
96-
const userDoc = await getDoc(userRef);
97-
console.log(userDoc);
98-
99-
if (userDoc.exists()) {
100-
// Update existing document: push new remark to array
101-
await updateDoc(userRef, {
102-
remarks: arrayUnion({
103-
text: remark,
104-
date: Timestamp.fromDate(new Date(date)),
105-
createdAt: Timestamp.now()
106-
}),
107-
updatedAt: Timestamp.now()
108-
});
109-
} else {
110-
// Create new document with remarks array
111-
await setDoc(userRef, {
112-
email: email,
113-
remarks: [
114-
{
115-
text: remark,
116-
date: Timestamp.fromDate(new Date(date)),
117-
createdAt: Timestamp.now()
118-
}
119-
],
120-
createdAt: Timestamp.now(),
121-
updatedAt: Timestamp.now()
122-
});
123-
}
124-
125-
alert("Remark added successfully!");
126-
} catch (error) {
127-
console.error("Error adding consultancy remark:", error);
128-
alert("Failed to add remark. Please try again.");
129-
}
130-
}
88+
// async function addConsultancyRemark(email, remark, date) {
89+
// if (!email || !remark || !date) {
90+
// alert("Please enter a remark and select a valid date.");
91+
// return;
92+
// }
93+
94+
// try {
95+
// const userRef = doc(db, "user_consultancies", email); // Use email as document ID
96+
// const userDoc = await getDoc(userRef);
97+
// console.log(userDoc);
98+
99+
// if (userDoc.exists()) {
100+
// // Update existing document: push new remark to array
101+
// await updateDoc(userRef, {
102+
// remarks: arrayUnion({
103+
// text: remark,
104+
// date: Timestamp.fromDate(new Date(date)),
105+
// createdAt: Timestamp.now()
106+
// }),
107+
// updatedAt: Timestamp.now()
108+
// });
109+
// } else {
110+
// // Create new document with remarks array
111+
// await setDoc(userRef, {
112+
// email: email,
113+
// remarks: [
114+
// {
115+
// text: remark,
116+
// date: Timestamp.fromDate(new Date(date)),
117+
// createdAt: Timestamp.now()
118+
// }
119+
// ],
120+
// createdAt: Timestamp.now(),
121+
// updatedAt: Timestamp.now()
122+
// });
123+
// }
124+
125+
// alert("Remark added successfully!");
126+
// } catch (error) {
127+
// console.error("Error adding consultancy remark:", error);
128+
// alert("Failed to add remark. Please try again.");
129+
// }
130+
// }
131131

132132
//Function to add interview feedback (stored as an array)
133133

@@ -517,12 +517,14 @@ let currentPage = 1;
517517
const rowsPerPage = 5;
518518

519519
//function to populate table
520+
520521
async function populateUserProfilesTable(data) {
521522
const tableBody = document.querySelector("#userProfilesTable tbody");
522523
tableBody.innerHTML = ""; // Clear existing rows
523524

524525
try {
525526
let selectedRating = document.getElementById("ratingDropdown").value; // Get selected rating
527+
const globalSearchValue = document.getElementById("globalSearch").value.toLowerCase().trim();
526528
let filteredUsers = [];
527529

528530
if (selectedRating && selectedRating !== "all") {
@@ -534,6 +536,65 @@ async function populateUserProfilesTable(data) {
534536
console.log("Selected Rating:", selectedRating);
535537
console.log("Filtered Users:", filteredUsers);
536538

539+
// calculating experience
540+
function calculateExperience(start, end) {
541+
const startDate = new Date(start);
542+
const endDate = new Date(end);
543+
if (isNaN(startDate) || isNaN(endDate)) return "Invalid dates";
544+
545+
const months =
546+
(endDate.getFullYear() - startDate.getFullYear()) * 12 +
547+
(endDate.getMonth() - startDate.getMonth());
548+
549+
if (months < 12) return `${months} months`;
550+
const years = Math.floor(months / 12);
551+
const remMonths = months % 12;
552+
return `${years} year${years > 1 ? "s" : ""}${remMonths ? ` ${remMonths} months` : ""}`;
553+
}
554+
// Apply Global Search Filtering (after all other filters)
555+
if (globalSearchValue) {
556+
filteredUsers = filteredUsers.filter(user => {
557+
const values = [
558+
user.about?.firstName,
559+
user.about?.lastName,
560+
user.about?.email,
561+
user.about?.gender,
562+
user.education?.[0]?.school,
563+
user.education?.[0]?.degree,
564+
user.education?.[0]?.graduation_date,
565+
user.about?.dob ? calculateAge(user.about.dob).toString() + " years" : "",
566+
user.skills?.join(", "),
567+
user.social?.github,
568+
user.social?.instagram,
569+
user.social?.linkedin,
570+
user.social?.leetcode,
571+
...(user.experience || []).map(exp => {
572+
const duration = calculateExperience(exp.startDate, exp.endDate);
573+
return `${exp.companyName} ${duration}`;
574+
}),
575+
user.address?.present?.address,
576+
user.address?.present?.city,
577+
user.address?.present?.state,
578+
user.address?.present?.zip,
579+
user.address?.permanent?.address,
580+
user.address?.permanent?.city,
581+
user.address?.permanent?.state,
582+
user.address?.permanent?.zip,
583+
user.rating?.toString(),
584+
user.interview?.feedback || ""
585+
];
586+
return values.filter(Boolean).some(field =>
587+
typeof field === "string" && field.toLowerCase().includes(globalSearchValue)
588+
);
589+
590+
591+
// Check if any field includes the search term
592+
return values.some(field =>
593+
typeof field === "string" && field.toLowerCase().includes(globalSearchValue)
594+
);
595+
});
596+
}
597+
537598
if (!Array.isArray(filteredUsers)||filteredUsers.length === 0) {
538599
tableBody.innerHTML = "<tr><td colspan='14'>No users found</td></tr>";
539600
updatePaginationControls(0);
@@ -592,21 +653,7 @@ console.log("Filtered Users:", filteredUsers);
592653
593654
`;
594655

595-
// calculating experience
596-
function calculateExperience(start, end) {
597-
const startDate = new Date(start);
598-
const endDate = new Date(end);
599-
if (isNaN(startDate) || isNaN(endDate)) return "Invalid dates";
600-
601-
const months =
602-
(endDate.getFullYear() - startDate.getFullYear()) * 12 +
603-
(endDate.getMonth() - startDate.getMonth());
604-
605-
if (months < 12) return `${months} months`;
606-
const years = Math.floor(months / 12);
607-
const remMonths = months % 12;
608-
return `${years} year${years > 1 ? "s" : ""}${remMonths ? ` ${remMonths} months` : ""}`;
609-
}
656+
610657

611658
// Rating Dropdown
612659
// const ratingCell = document.createElement("td");
@@ -677,6 +724,12 @@ row.appendChild(ratingCell);
677724
console.error("Error getting user profiles:", error);
678725
}
679726
}
727+
function handleGlobalSearch() {
728+
populateUserProfilesTable();
729+
}
730+
window.handleGlobalSearch = handleGlobalSearch;
731+
732+
680733

681734
// calculating age from dob
682735
function calculateAge(dob) {

0 commit comments

Comments
 (0)