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 (
Active job listings: {activeJobListingsCount}
{recruiterDetails.companyDescription ? recruiterDetails.companyDescription : "There is no info about this company yet." }
{recruiterDetails.contactEmail} • {recruiterDetails.contactPhoneNumber} {recruiterDetails.receptionist && • {recruiterDetails.receptionist}}