From efd41c2233dcb6c93490c0c5c2c8a3f0f463f5b3 Mon Sep 17 00:00:00 2001 From: AryanGKulkarni <95529889+AryanGKulkarni@users.noreply.github.com> Date: Tue, 10 Sep 2024 17:25:00 +0530 Subject: [PATCH] Removed assign company,recruiter (#161) Co-authored-by: samnotfound404 --- src/app/(routes)/admin/jobs/[jobId]/page.tsx | 632 +++---------------- src/helpers/recruiter/types.ts | 24 +- 2 files changed, 124 insertions(+), 532 deletions(-) diff --git a/src/app/(routes)/admin/jobs/[jobId]/page.tsx b/src/app/(routes)/admin/jobs/[jobId]/page.tsx index 8795d2ec..88c1f3b0 100644 --- a/src/app/(routes)/admin/jobs/[jobId]/page.tsx +++ b/src/app/(routes)/admin/jobs/[jobId]/page.tsx @@ -18,8 +18,8 @@ import { fetchJobById } from "@/helpers/api"; import Loader from "@/components/Loader/loader"; import toast from "react-hot-toast"; import JobCoordinatorForm from "@/components/Admin/AddForms"; -import { fetchCompany, fetchRecruiterData, fetchFaculties, postFacultyApproval } from "@/helpers/api"; -import { assignCompany, postCompany, assignRecruiter, postRecruiter, fetchApprovals } from "@/helpers/api"; +import { fetchRecruiterData, fetchFaculties, postFacultyApproval } from "@/helpers/api"; +import { postCompany, postRecruiter, fetchApprovals } from "@/helpers/api"; import Select from "react-select"; const currentStatusOptions = [ "INITIALIZED", @@ -46,14 +46,6 @@ const JobDetailPage = ({ params }: { params: { jobId: string } }) => { const [facultyApprovals, setFacultyApprovals] = useState([]); const [selectedFaculties, setSelectedFaculties] = useState([]); const [facultyDropDown, setFacultyDropdown] = useState([false]); - const [companyData, setCompanyData] = useState(null); - const [recruiterData, setRecruiterData] = useState(null); - const [companyDropDown, setcompanyDropDown] = useState(false); - const [recruiterDropDown, setrecruiterDropDown] = useState(false); - const [selectedCompany, setSelectedCompany] = useState(null); - const [selectedRecruiter, setSelectedRecruiter] = useState(null); - const [toggleCompanyModal, setToggleCompanyModal] = useState(false); - const [toggleRecruiterModal, setToggleRecruiterModal] = useState(false); const [approvalModal, setApprovalModal] = useState(false); const [companyFormData, setCompanyFormData] = useState({ name: '', @@ -91,11 +83,10 @@ const JobDetailPage = ({ params }: { params: { jobId: string } }) => { const fetchData = async () => { try { - const [jobDetailData, jafDetailsData, companyData, recruiterData, facultyData] = + const [jobDetailData, jafDetailsData, recruiterData, facultyData] = await Promise.all([ fetchJobById(params.jobId), getJafDetails(), - fetchCompany(), fetchRecruiterData(), fetchFaculties(), ]); @@ -104,44 +95,7 @@ const JobDetailPage = ({ params }: { params: { jobId: string } }) => { setData(jobDetailData); setFormData(jobDetailData); setFacultyData(facultyData); - setCompanyData(companyData); - setRecruiterData(recruiterData); - setRecruiterFormData({ - designation: jobDetailData.recruiterDetailsFilled.designation, - landline: jobDetailData.recruiterDetailsFilled.landline, - companyId: jobDetailData.company.id, // Assuming you have a companyId in jobDetailData - user: { - name: jobDetailData.recruiterDetailsFilled.name, - email: jobDetailData.recruiterDetailsFilled.email, - contact: jobDetailData.recruiterDetailsFilled.contact - } - }); - setCompanyFormData({ - name: jobDetailData.companyDetailsFilled.name, - size: jobDetailData.companyDetailsFilled.size, - category: jobDetailData.companyDetailsFilled.category, - yearOfEstablishment: jobDetailData.companyDetailsFilled.yearOfEstablishment, - website: jobDetailData.companyDetailsFilled.website, - annualTurnover: jobDetailData.companyDetailsFilled.annualTurnover || '', - socialMediaLink: jobDetailData.companyDetailsFilled.socialMediaLink || '', - address: { - line1: jobDetailData.companyDetailsFilled.address.line1 || '', - line2: jobDetailData.companyDetailsFilled.address.line2 || '', - city: jobDetailData.companyDetailsFilled.address.city || '', - state: jobDetailData.companyDetailsFilled.address.state || '', - country: jobDetailData.companyDetailsFilled.address.country || '' - }, - domains: jobDetailData.companyDetailsFilled.domains || [''] - }); - - const matchedCompany = companyData.find( - (company) => company.id === jobDetailData.company.id, - ); - setSelectedCompany(matchedCompany); - const matchedRecruiter = recruiterData.find( - (recruiter) => recruiter.id === jobDetailData.recruiter.id, - ); - setSelectedRecruiter(matchedRecruiter); + } catch (error) { toast.error("Error fetching data"); } finally { @@ -151,104 +105,6 @@ const JobDetailPage = ({ params }: { params: { jobId: string } }) => { fetchData(); }, [params.jobId]); - const handleCompanyFormChange = (e) => { - const { name, value } = e.target; - setCompanyFormData((prevFormData) => ({ - ...prevFormData, - [name]: value, - })); - }; - - const handleRecruiterFormChange = (e) => { - const { name, value } = e.target; - const [mainKey, subKey] = name.split('.'); - - if (subKey) { - setRecruiterFormData((prevFormData) => ({ - ...prevFormData, - [mainKey]: { - ...prevFormData[mainKey], - [subKey]: value - } - })); - } else { - setRecruiterFormData((prevFormData) => ({ - ...prevFormData, - [name]: value - })); - } - }; - - const handleCompanyFormSubmit = async () => { - try { - await postCompany([{ - name: companyFormData.name, - category: companyFormData.category, - yearOfEstablishment: companyFormData.yearOfEstablishment, - website: companyFormData.website, - size: companyFormData.size, - annualTurnover: companyFormData.annualTurnover, - socialMediaLink: "companyFormData.socialMediaLink", - domains: companyFormData.domains, - address: { - line1: companyFormData.address.line1, - line2: companyFormData.address.line2, - city: companyFormData.address.city, - state: companyFormData.address.state, - country: companyFormData.address.country - } - }]); - toast.success("Company details updated successfully!"); - window.location.reload(); - } catch (error) { - toast.error("Error updating company details"); - } - }; - - const handleRecruiterFormSubmit = async () => { - try { - await postRecruiter([{ - designation: recruiterFormData.designation, - landline: recruiterFormData.landline, - companyId: recruiterFormData.companyId, - user: { - name: recruiterFormData.user.name, - email: recruiterFormData.user.email, - contact: recruiterFormData.user.contact - } - }]); - toast.success("Recruiter details updated successfully!"); - window.location.reload(); - } catch (error) { - toast.error("Error updating recruiter details"); - } - }; - const handleToggleModal = (type) => { - if (type === "company") { - setToggleCompanyModal(prevState => !prevState); - } else if (type === "recruiter") { - setToggleRecruiterModal(prevState => !prevState); - } - }; - const toggleDropdown = (state: string) => { - if (state === "company") { - setcompanyDropDown(!companyDropDown); - setrecruiterDropDown(false); - } else { - setrecruiterDropDown(!recruiterDropDown); - setcompanyDropDown(false); - } - }; - - const handleCompanySelect = (company) => { - setSelectedCompany(company); - setcompanyDropDown(false); - }; - const handleRecruiterSelect = (recruiter) => { - setSelectedRecruiter(recruiter); - setrecruiterDropDown(false); - }; - const updateFacultyDropDown = (index, value) => { setFacultyDropdown(prevState => { const newState = [...prevState]; @@ -260,7 +116,7 @@ const JobDetailPage = ({ params }: { params: { jobId: string } }) => { const submitApproval = async (salaryIndex) => { const selected = selectedFaculties[salaryIndex] || []; const res = await postFacultyApproval(job.salaries[salaryIndex].id, selected); - if(res) toast.success("Request Sent"); + if (res) toast.success("Request Sent"); else toast.error("Error Sending Request"); updateFacultyDropDown(salaryIndex, false); }; @@ -358,26 +214,26 @@ const JobDetailPage = ({ params }: { params: { jobId: string } }) => { )}
- - Registration Status - {editMode ? ( + + Registration Status + {editMode ? ( { setFormData((form) => ({ ...form, - registration: e.target.checked?"OPEN":"CLOSED", + registration: e.target.checked ? "OPEN" : "CLOSED", })); }} /> ) : ( - {job.registration==="OPEN" ? "Open" : "Closed"} + {job.registration === "OPEN" ? "Open" : "Closed"} )} - +
Current Status @@ -503,139 +359,16 @@ const JobDetailPage = ({ params }: { params: { jobId: string } }) => {
Company Details
-
+
Company Name
-
- {companyDropDown ? ( -
- toggleDropdown("company")} - readOnly - /> - {companyDropDown && ( -
-
- {companyData.map((company) => ( -
handleCompanySelect(company)} - > - {company.name} -
- ))} -
-
- -
-
- {toggleCompanyModal && ( -
-
-
-

Edit Company Details

- -
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
-
- -
-
-
- )} - -
- -
- )} -
- ) : ( -
-
toggleDropdown("company")} - className="cursor-pointer w-full" - > - {selectedCompany?.name || "Select a Company"} -
- -
- )} +
+
{job.company?.name}
Annual Turnover
-
{selectedCompany?.annualTurnover}
+
{job.company?.annualTurnover}
@@ -643,13 +376,13 @@ const JobDetailPage = ({ params }: { params: { jobId: string } }) => { Year of Establishment
-
{selectedCompany?.yearOfEstablishment}
+
{job.company?.yearOfEstablishment}
Category
-
{selectedCompany?.category}
+
{job.company?.category}
@@ -657,215 +390,52 @@ const JobDetailPage = ({ params }: { params: { jobId: string } }) => {
-
- -
-
Recruiter Details
+
Recruiter Details
-
-
Recruiter Name
-
- {recruiterDropDown ? ( -
- toggleDropdown("recruiter")} - readOnly - /> - {recruiterDropDown && ( -
-
- {recruiterData.map((recruiter) => ( -
handleRecruiterSelect(recruiter)} - > - {recruiter.user.name} -
- ))} -
-
- -
-
- {toggleRecruiterModal && ( -
-
-
-

Edit Recruiter Details

- -
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
-
- -
-
-
- )} - - - -
- -
- )} -
- ) : ( -
-
toggleDropdown("recruiter")} - className="cursor-pointer w-full" - > - {selectedRecruiter?.user.name || "Select a Recruiter"} -
- -
- )} -
-
-
Name
-
{selectedRecruiter?.user.name}
+
{job.recruiter.user.name}
+
-
Email
+
Designation
-
{selectedRecruiter?.user.email}
+
{job.recruiter.designation}
-
Contact
+
Company
-
{selectedRecruiter?.user.contact}
+
{job.company.name}
-
Company
+
Email
-
{selectedRecruiter?.company.name}
+
{job.recruiter.user.email}
-
Designation
+
Contact
-
{selectedRecruiter?.designation}
+
{job.recruiter.user.contact}
-
- -
@@ -1240,7 +810,7 @@ const JobDetailPage = ({ params }: { params: { jobId: string } }) => {
{salary.baseSalary}
)}
-
+
CTC
{editMode ? ( {
{salary.totalCTC}
)}
-
+
Take Home Salary
{editMode ? ( {
{salary.takeHomeSalary}
)}
-
+
Gross Salary
{editMode ? ( {
{salary.grossSalary}
)}
-
+
Other Compensations
{editMode ? ( { ) : (
{salary.otherCompensations}
)} -
+
-
-
Minimum CPI
- {editMode ? ( - { - const updatedSalaries = formData.salaries.map((s, i) => - i === salaryIndex ? { ...s, minCPI: e.target.value } : s - ); - setFormData((prev) => ({ - ...prev, - salaries: updatedSalaries, - })); - }} - /> - ) : ( -
{salary.minCPI}
- )} -
-
-
Tenth Marks
- {editMode ? ( - { - const updatedSalaries = formData.salaries.map((s, i) => - i === salaryIndex ? { ...s, tenthMarks: e.target.value } : s - ); - setFormData((prev) => ({ - ...prev, - salaries: updatedSalaries, - })); - }} - /> - ) : ( -
{salary.tenthMarks}
- )} -
-
-
TwelthMarks Marks
- {editMode ? ( - { - const updatedSalaries = formData.salaries.map((s, i) => - i === salaryIndex ? { ...s, twelthMarks: e.target.value } : s - ); - setFormData((prev) => ({ - ...prev, - salaries: updatedSalaries, - })); - }} - /> - ) : ( -
{salary.twelthMarks}
- )} -
+
+
Minimum CPI
+ {editMode ? ( + { + const updatedSalaries = formData.salaries.map((s, i) => + i === salaryIndex ? { ...s, minCPI: e.target.value } : s + ); + setFormData((prev) => ({ + ...prev, + salaries: updatedSalaries, + })); + }} + /> + ) : ( +
{salary.minCPI}
+ )}
+
+
Tenth Marks
+ {editMode ? ( + { + const updatedSalaries = formData.salaries.map((s, i) => + i === salaryIndex ? { ...s, tenthMarks: e.target.value } : s + ); + setFormData((prev) => ({ + ...prev, + salaries: updatedSalaries, + })); + }} + /> + ) : ( +
{salary.tenthMarks}
+ )} +
+
+
TwelthMarks Marks
+ {editMode ? ( + { + const updatedSalaries = formData.salaries.map((s, i) => + i === salaryIndex ? { ...s, twelthMarks: e.target.value } : s + ); + setFormData((prev) => ({ + ...prev, + salaries: updatedSalaries, + })); + }} + /> + ) : ( +
{salary.twelthMarks}
+ )} +
+
{/* Genders */}

Genders

@@ -1444,7 +1014,7 @@ const JobDetailPage = ({ params }: { params: { jobId: string } }) => { {facultyDropDown[salaryIndex] && ()}
- )} + )}
diff --git a/src/helpers/recruiter/types.ts b/src/helpers/recruiter/types.ts index 3c323e90..c12a82ab 100644 --- a/src/helpers/recruiter/types.ts +++ b/src/helpers/recruiter/types.ts @@ -75,10 +75,32 @@ export interface JobDetailFC { year: string; type: string; }; - company: { + company: { + name: string; + domains: string[]; + category: string; + address: { + city: string; + line1: string; + line2: string; + state: string; + country: string; + }; + size: number; + yearOfEstablishment: string; + annualTurnover: string; + socialMediaLink: string; +}; +recruiter : { + designation: string; + id: string; + user: { id: string; + email: string; name: string; + contact: string; }; +}; selectionProcedure: { selectionMode: string; shortlistFromResume: true;