Changeset befb988 for jobvista-frontend/src/views/dashboard
- Timestamp:
- 06/17/24 21:59:14 (5 months ago)
- Branches:
- main
- Children:
- 08f82ec
- Parents:
- b248810
- Location:
- jobvista-frontend/src/views/dashboard
- Files:
-
- 1 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
jobvista-frontend/src/views/dashboard/Dashboard.js
rb248810 rbefb988 1 import ". /Dashboard.css"1 import "../shared_css/Random.css" 2 2 3 3 import {useDispatch, useSelector} from "react-redux"; … … 12 12 import {AUTH_TOKEN} from "../../axios/axiosInstance"; 13 13 import {jwtDecode} from "jwt-decode"; 14 15 export const Dashboard = (props) => { 14 import {RecruiterActions} from "../../redux/actions/recruiterActions"; 15 16 export const Dashboard = () => { 16 17 17 18 const dispatch = useDispatch(); … … 19 20 const [jobAdvertisements, setJobAdvertisements] = useState([]); 20 21 let jobAdvertisementsState = useSelector(state => state.jobAd.jobAdvertisements) 22 const [jobDispatched, setJobDispatched] = useState(false); 23 24 const [logos, setLogos] = useState({}); 25 let logosState = useSelector(state => state.images.logos) 26 const [logoDispatched, setLogoDispatched] = useState(false); 27 21 28 const auth = useSelector(state => state.auth); 22 29 … … 25 32 const [selectedIndustry, setSelectedIndustry] = useState("all"); 26 33 const [searchTerm, setSearchTerm] = useState(""); 27 const [dispatched, setDispatched] = useState(false) 34 35 28 36 29 37 // const [user, setUser] = useState(null); … … 54 62 55 63 useEffect(() => { 56 if (! dispatched && jobAdvertisementsState.length == 0) {64 if (!jobDispatched && jobAdvertisementsState.length == 0) { 57 65 dispatch(JobAdvertisementActions.fetchJobAdvertisements((success, response) => { 58 66 if (success && response.data.length > 0) { 59 setJobAdvertisements(sortElementsBy(response.data ))67 setJobAdvertisements(sortElementsBy(response.data, "postedOn")) 60 68 } 61 set Dispatched(true)69 setJobDispatched(true) 62 70 console.log("Fetch all job advertisements GET") 63 71 })) … … 66 74 setJobAdvertisements(jobAdvertisementsState) 67 75 console.log("Fetch all job advertisements STATE") 76 77 68 78 } 69 79 }, [jobAdvertisementsState]) 80 81 useEffect(() => { 82 83 if(jobDispatched && !logoDispatched) { 84 jobAdvertisements.forEach(jobAd => { 85 if(jobAd.recruiterId && !logos[jobAd.recruiterId]) { 86 fetchLogo(jobAd.recruiterId); 87 } 88 }) 89 setLogoDispatched(true) 90 console.log("Fetch all logos GET") 91 } else { 92 setLogos(logosState) 93 console.log("Fetch all logos STATE") 94 } 95 96 }, [jobDispatched, logosState]) 97 98 const fetchLogo = (recruiterId) => { 99 dispatch(RecruiterActions.downloadLogo(recruiterId, (success, response) => { 100 if(success) { 101 setLogos(prevLogos => ({...prevLogos, [recruiterId]: response})) 102 } 103 })); 104 }; 70 105 71 106 let filterJobAdvertisements = () => { … … 86 121 87 122 <div className="container"> 88 <div className=" head-dashboard-box">123 <div className="filter-container"> 89 124 <div className="row"> 90 <div className="col-md-12 filter- container">125 <div className="col-md-12 filter-box"> 91 126 <div className="search-container"> 92 127 <i className="fa-solid fa-magnifying-glass search-icon"></i> … … 117 152 /> 118 153 </div> 119 <button onClick={filterJobAdvertisements} className="b tn-open-modal">Find jobs</button>154 <button onClick={filterJobAdvertisements} className="blue-submit-button">Find jobs</button> 120 155 </div> 121 {/*<div className="col-md-3">*/}122 123 {/*<div className="date-range-section item">*/}124 {/* <Select*/}125 {/* defaultValue={{value: "all", label: "Lifetime"}}*/}126 {/* //value={selectedDateRange.value}*/}127 {/* //onChange={option => setSelectedDateRange(option.value)}*/}128 {/* options={dataRangeOptions}*/}129 {/* className="date-range sort"*/}130 {/* />*/}131 {/*</div>*/}132 {/*</div>*/}133 156 </div> 134 157 </div> 135 <div className="row row-cols-1 row-cols-md-4 g-4"> 136 158 <div className="row row-cols-2 row-cols-md-4 g-4"> 137 159 {jobAdvertisements && 138 160 jobAdvertisements.map((jobAd, index) => ( … … 146 168 </div> 147 169 <div className="card-body"> 170 <img 171 // loading gif 172 src={logos[jobAd.recruiterId]} 173 alt="" 174 width={100} height={100} 175 /> 148 176 <h5 className="card-title">{jobAd.title}</h5> 149 177 <span>{jobAd.industry} • <span style={{
Note:
See TracChangeset
for help on using the changeset viewer.