source: jobvista-frontend/src/views/applications/ApplicationsByJobSeeker.js@ befb988

main
Last change on this file since befb988 was befb988, checked in by 223021 <daniel.ilievski.2@…>, 2 weeks ago

Added an edit profile page for both job seekers and recruiters, where they can upload profile pictures/company logos and edit their profile data. Added profile page specifically for recruiters. Refactored existing code.

  • Property mode set to 100644
File size: 5.5 KB
Line 
1import {useDispatch, useSelector} from "react-redux";
2import {useEffect, useState} from "react";
3import {ApplicationActions} from "../../redux/actions/applicationActions";
4import {ApplicationDetailsModal} from "./ApplicationDetailsModal";
5import Select from "react-select";
6
7import {RecruiterActions} from "../../redux/actions/recruiterActions";
8import {sortElementsBy} from "../../utils/utils";
9
10export const ApplicationsByJobSeeker = () => {
11 const dispatch = useDispatch();
12 const auth = useSelector(state => state.auth.currentUser);
13
14 const [applicationsByJobSeeker, setApplicationsByJobSeeker] = useState([]);
15 let applicationsByJobSeekerState = useSelector(state => state.appl.applicationsByJobSeeker);
16 const [dispatched, setDispatched] = useState(false);
17
18 const [logos, setLogos] = useState({});
19 let logosState = useSelector(state => state.images.logos)
20 const [logoDispatched, setLogoDispatched] = useState(false);
21
22
23
24 useEffect(() => {
25 if(!dispatched && (applicationsByJobSeekerState.length === 0 || applicationsByJobSeekerState.length === 1) ) {
26 dispatch(ApplicationActions.fetchApplicationsByJobSeeker(auth.id, (success, response) => {
27 if(success && response.data.length > 0) {
28 setApplicationsByJobSeeker(sortElementsBy(response.data, "submittedOn"));
29 }
30 setDispatched(true)
31 console.log("Fetch applications by job seeker GET")
32 }))
33
34 } else {
35 setApplicationsByJobSeeker(sortElementsBy(applicationsByJobSeekerState, "submittedOn"));
36 console.log("Fetch applications by job seeker STATE")
37 }
38 }, [applicationsByJobSeekerState])
39
40 useEffect(() => {
41
42 if(dispatched && !logoDispatched) {
43 applicationsByJobSeeker.forEach(jobAd => {
44 if(jobAd.recruiterId && !logos[jobAd.recruiterId]) {
45 fetchLogo(jobAd.recruiterId);
46 }
47 })
48 setLogoDispatched(true)
49 console.log("Fetch all logos GET")
50 } else if (logoDispatched){
51 setLogos(logosState)
52 console.log("Fetch all logos STATE")
53
54 }
55
56 }, [dispatched, logosState])
57
58
59
60 const fetchLogo = (recruiterId) => {
61 dispatch(RecruiterActions.downloadLogo(recruiterId, (success, response) => {
62 if(success) {
63 setLogos(prevLogos => ({...prevLogos, [recruiterId]: response}))
64 }
65 }));
66 };
67
68 const options = [
69 {value: 'PROPOSED', label: <span className="status" style={{backgroundColor: '#4A90E2'}}><i className="fa-solid fa-paper-plane"></i> Proposed</span>},
70 {value: 'UNDER_REVIEW', label: <span className="status" style={{backgroundColor: '#F5A623'}}><i className="fa-solid fa-file-pen"></i> Under Review</span>},
71 {value: 'ACCEPTED', label: <span className="status" style={{backgroundColor: '#7ED321'}}><i className="fa-solid fa-user-check"></i> Accepted</span>},
72 {value: 'DENIED', label: <span className="status" style={{backgroundColor: '#D0021B'}}><i className="fa-solid fa-user-slash"></i> Denied</span>}
73 ];
74
75 let handleDefaultValue = (status) => {
76 return options.find(option => option.value === status);
77 }
78
79
80
81 return (
82 <div className="custom-container">
83
84 <div className="application-title">
85 <h3>Application history</h3>
86 </div>
87 {applicationsByJobSeeker && applicationsByJobSeeker.map((application, index) => (
88 <div key={index} className="application-card">
89 <div className="app-company-logo">
90 <img
91 // loading gif
92 src={logosState[application.recruiterId]}
93 alt=""
94 width={75} height={75}
95 />
96 </div>
97
98 <div className="app-info">
99 <div className="jobAd-title">{application.jobAdTitle}</div>
100 <div className="contact-info">
101 <div className="contact-item">
102 <i className="fa-solid fa-building"></i> <span>{application.recruiterName}</span>
103 </div>
104 <div className="contact-item">
105 <i className="fa-solid fa-envelope"></i> <span>{application.recruiterEmail}</span>
106 </div>
107 <div className="contact-item">
108 <i className="fa-solid fa-phone"></i> <span>{application.recruiterPhoneNumber}</span>
109 </div>
110 <span> • Submitted on <b>{new Date(application.submittedOn).toLocaleString('default', {
111 day: 'numeric',
112 month: 'long',
113 year: 'numeric'
114 })}</b></span>
115 </div>
116 </div>
117
118 <div className="app-status">
119 <ApplicationDetailsModal application={application}/>
120 <> {handleDefaultValue(application.status).label}</>
121 {/*<div className="select">*/}
122 {/* <Select isDisabled={true} options={options} />*/}
123 {/*</div>*/}
124
125 </div>
126 </div>
127 ))}
128
129 </div>
130 )
131}
Note: See TracBrowser for help on using the repository browser.