Changeset 19398ad for jobvista-frontend/src/views/dashboard
- Timestamp:
- 05/16/24 23:09:21 (6 months ago)
- Branches:
- main
- Children:
- 28b3398
- Parents:
- d8b6c91
- Location:
- jobvista-frontend/src/views/dashboard
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
jobvista-frontend/src/views/dashboard/Dashboard.js
rd8b6c91 r19398ad 1 import "./Dashboard.css" 2 3 import {useDispatch, useSelector} from "react-redux"; 4 import {useEffect, useState} from "react"; 5 import {JobAdvertisementActions} from "../../redux/actions/jobAdvertisementActions"; 6 import {formatRelativeTime, sortElementsByDateCreated} from "../../utils/utils"; 7 import {dataRangeOptions, industryOptions, industryOptionsFilter, sortOptions} from "../selectOptions"; 8 import Select from "react-select"; 9 import Roles from "../../enumerations/Roles"; 10 import {Link} from "react-router-dom"; 11 import JobType from "../../enumerations/JobType"; 12 1 13 export const Dashboard = () => { 14 15 const dispatch = useDispatch(); 16 17 const [jobAdvertisements, setJobAdvertisements] = useState([]); 18 let jobAdvertisementsState = useSelector(state => state.jobAd.jobAdvertisements) 19 const auth = useSelector(state => state.auth.currentUser); 20 21 const [role, setRole] = useState(""); 22 const [sortOrder, setSortOrder] = useState("newest"); 23 const [selectedDateRange, setSelectedDateRange] = useState("all"); 24 const [searchTerm, setSearchTerm] = useState(""); 25 const [dispatched, setDispatched] = useState(false) 26 27 useEffect(() => { 28 if (auth) { 29 setRole(auth.role); 30 } 31 }, [auth]); 32 33 useEffect(() => { 34 if(!dispatched && jobAdvertisementsState.length == 0) { 35 dispatch(JobAdvertisementActions.fetchJobAdvertisements((success, response) => { 36 if (success && response.data.length > 0) { 37 setJobAdvertisements(sortElementsByDateCreated(response.data)) 38 } 39 setDispatched(true) 40 console.log("Fetch all job advertisements GET") 41 console.log(response.data) 42 })) 43 44 } else { 45 setJobAdvertisements(jobAdvertisementsState) 46 console.log("Fetch all job advertisements STATE") 47 } 48 }, []) 2 49 3 50 4 51 return ( 5 52 <div className="container"> 6 <div className="row justify-content"> 7 <div className="col-md-4"> 8 <div className="card"> 9 <h5 className="card-title">Job Listing Name</h5> 10 <p>Job Listing Data</p> 53 <div className="head-dashboard-box"> 54 <div className="row"> 55 <div className="col-md-3"> 56 <div className="search-container head-component"> 57 <i className="fa-solid fa-magnifying-glass blue-colored"></i> 58 <input 59 className="search-input" 60 type="text" 61 placeholder="Search job advertisement by title..." 62 //value={searchTerm} 63 //onChange={event => setSearchTerm(event.target.value)} 64 /> 65 </div> 11 66 </div> 12 </div> 13 <div className="col-md-4"> 14 <div className="card"> 15 <h5 className="card-title">Job Listing Name</h5> 16 <p>Job Listing Data</p> 17 </div> 18 </div> 19 <div className="col-md-4"> 20 <div className="card"> 21 <h5 className="card-title">Job Listing Name</h5> 22 <p>Job Listing Data</p> 67 <div className="col-md-9"> 68 <div className="sort-section item"> 69 <Select 70 defaultValue={{value: "all", label: "All industries"}} 71 //value={sortOrder.value} 72 //onChange ={option => setSortOrder(option.value)} 73 options={industryOptionsFilter} 74 className="sort-range sort" 75 /> 76 </div> 77 <div className="sort-section item"> 78 <Select 79 defaultValue={{value: "newest", label: "Date (Newest First)"}} 80 //value={sortOrder.value} 81 //onChange ={option => setSortOrder(option.value)} 82 options = {sortOptions} 83 className="sort-range sort" 84 /> 85 </div> 86 <div className="date-range-section item"> 87 <Select 88 defaultValue={{value: "all", label: "Lifetime"}} 89 //value={selectedDateRange.value} 90 //onChange={option => setSelectedDateRange(option.value)} 91 options={dataRangeOptions} 92 className="date-range sort" 93 /> 94 </div> 23 95 </div> 24 96 </div> 25 97 </div> 98 <div className="row row-cols-1 row-cols-md-4 g-4"> 26 99 100 {jobAdvertisements && 101 jobAdvertisements.map((jobAd, index) => ( 102 <div key={index} className="col"> 103 <div className="custom-card"> 104 <div className="card-head"> 105 <span className="hourly-salary"><b>${jobAd.startingSalary}/hr</b></span> 106 <span className="job-type"> {jobAd.jobType===JobType.JOB ? "Job" : "Internship"}</span> 107 {!jobAd.active && <span className="expired">Expired</span>} 108 </div> 109 <div className="card-body"> 110 <h5 className="card-title">{jobAd.title}</h5> 111 <span>{jobAd.industry} • <span style={{color: "black", fontWeight: "bold"}}>{formatRelativeTime(jobAd.postedOn)}</span></span> 112 <div className="card-info"> 113 <span><i className="fa-solid fa-building" style={{color: "#000000"}}></i> Company: <span style={{color: "black", fontWeight: "bold"}}>{jobAd.recruiterName}</span></span> <br/> 114 </div> 115 116 <div className="aligned"> 117 <Link to={`/job-advertisements/view/${jobAd.id}`} className="card-button">Read more</Link> 118 {role===Roles.JOBSEEKER && 119 <> 120 {jobAd.active && <button className="card-button">Apply now</button> } 121 {!jobAd.active && <button className="card-button disabled">Apply now</button> } 122 </> 123 } 124 </div> 125 126 </div> 127 </div> 128 </div> 129 ))} 130 131 </div> 27 132 </div> 28 133 )
Note:
See TracChangeset
for help on using the changeset viewer.