import "../job_advertisements/JobAdvertisements.css" import {useDispatch, useSelector} from "react-redux"; import {useEffect, useState} from "react"; import {JobAdvertisementActions} from "../../redux/actions/jobAdvertisementActions"; import {formatRelativeTime, sortElementsBy} from "../../utils/utils"; import {Link} from "react-router-dom"; import JobType from "../../enumerations/JobType"; import {RecruiterActions} from "../../redux/actions/recruiterActions"; import {useParams} from "react-router"; export const RecruiterProfile = () => { const dispatch = useDispatch(); const {id} = useParams(); const auth = useSelector(state => (state.auth.currentUser)) const [jobAdvertisementsByRecruiter, setJobAdvertisementsByRecruiter] = useState([]); const [recruiterDetails, setRecruiterDetails] = useState(null); let logosState = useSelector(state => state.images.logos) const [logoDispatched, setLogoDispatched] = useState(false) const [logoView, setLogoView] = useState(null); const [activeJobListingsCount, setActiveJobListingsCount] = useState(0); useEffect(() => { JobAdvertisementActions.fetchRecruiterDetailsById(id, (success, response) => { if (success) { setRecruiterDetails(response.data) } }) }, []); useEffect(() => { if (id) { if (!logoDispatched && !logosState[id]) { dispatch(RecruiterActions.downloadLogo(id, (success, response) => { if (success) { setLogoView(response) setLogoDispatched(true) } })) } else { setLogoView(logosState[id]) } } }, [auth]) useEffect(() => { dispatch(JobAdvertisementActions.fetchJobAdvertisementsByRecruiterProfile(id, (success, response) => { if (success && response.data.length > 0) { setJobAdvertisementsByRecruiter(sortElementsBy(response.data, "postedOn")) setActiveJobListingsCount(countActiveJobListings(response.data)); } })) }, []) function countActiveJobListings(jobAds) { if (jobAds.length > 0) { const activeJobListings = jobAds.filter(job => job.active) return activeJobListings.length; } return 0; } return (
Company Banner

{recruiterDetails && recruiterDetails.companyName}

Active job listings: {activeJobListingsCount}

{recruiterDetails && <>

About the company

{recruiterDetails.companyDescription ? recruiterDetails.companyDescription : "There is no info about this company yet." }

{recruiterDetails.contactEmail} {recruiterDetails.contactPhoneNumber} {recruiterDetails.receptionist && {recruiterDetails.receptionist}}

} {/*
*/} {/*
*/} {/*
*/} {/*
*/} {/*
*/} {/* */} {/* setSearchTerm(event.target.value)}*/} {/* />*/} {/*
*/} {/*
*/} {/* setSelectedIndustry(option.value)}*/} {/* options={industryOptionsFilter}*/} {/* className="sort-range sort"*/} {/* />*/} {/*
*/} {/*
*/} {/* setSelectedSortOrder(option.value)}*/} {/* options={sortOptions}*/} {/* className="sort-range sort"*/} {/* />*/} {/*
*/} {/* */} {/*
*/} {/*
*/} {/*
*/}
{jobAdvertisementsByRecruiter && jobAdvertisementsByRecruiter.map((jobAd, index) => (
${jobAd.startingSalary}/hr {jobAd.jobType === JobType.JOB ? "Job" : "Internship"} {!jobAd.active && Expired}
{jobAd.title}
{jobAd.industry} • {formatRelativeTime(jobAd.postedOn)}
Company: {jobAd.recruiterName}
Read more
))}
) }