Ignore:
Timestamp:
06/17/24 21:59:14 (5 months ago)
Author:
223021 <daniel.ilievski.2@…>
Branches:
main
Children:
08f82ec
Parents:
b248810
Message:

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.

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"
     1import "../shared_css/Random.css"
    22
    33import {useDispatch, useSelector} from "react-redux";
     
    1212import {AUTH_TOKEN} from "../../axios/axiosInstance";
    1313import {jwtDecode} from "jwt-decode";
    14 
    15 export const Dashboard = (props) => {
     14import {RecruiterActions} from "../../redux/actions/recruiterActions";
     15
     16export const Dashboard = () => {
    1617
    1718    const dispatch = useDispatch();
     
    1920    const [jobAdvertisements, setJobAdvertisements] = useState([]);
    2021    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
    2128    const auth = useSelector(state => state.auth);
    2229
     
    2532    const [selectedIndustry, setSelectedIndustry] = useState("all");
    2633    const [searchTerm, setSearchTerm] = useState("");
    27     const [dispatched, setDispatched] = useState(false)
     34
     35
    2836
    2937    // const [user, setUser] = useState(null);
     
    5462
    5563    useEffect(() => {
    56         if (!dispatched && jobAdvertisementsState.length == 0) {
     64        if (!jobDispatched && jobAdvertisementsState.length == 0) {
    5765            dispatch(JobAdvertisementActions.fetchJobAdvertisements((success, response) => {
    5866                if (success && response.data.length > 0) {
    59                     setJobAdvertisements(sortElementsBy(response.data))
     67                    setJobAdvertisements(sortElementsBy(response.data, "postedOn"))
    6068                }
    61                 setDispatched(true)
     69                setJobDispatched(true)
    6270                console.log("Fetch all job advertisements GET")
    6371            }))
     
    6674            setJobAdvertisements(jobAdvertisementsState)
    6775            console.log("Fetch all job advertisements STATE")
     76
     77
    6878        }
    6979    }, [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    };
    70105
    71106    let filterJobAdvertisements = () => {
     
    86121
    87122        <div className="container">
    88             <div className="head-dashboard-box">
     123            <div className="filter-container">
    89124                <div className="row">
    90                     <div className="col-md-12 filter-container">
     125                    <div className="col-md-12 filter-box">
    91126                        <div className="search-container">
    92127                            <i className="fa-solid fa-magnifying-glass search-icon"></i>
     
    117152                            />
    118153                        </div>
    119                         <button onClick={filterJobAdvertisements} className="btn-open-modal">Find jobs</button>
     154                        <button onClick={filterJobAdvertisements} className="blue-submit-button">Find jobs</button>
    120155                    </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>*/}
    133156                </div>
    134157            </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">
    137159                {jobAdvertisements &&
    138160                    jobAdvertisements.map((jobAd, index) => (
     
    146168                                </div>
    147169                                <div className="card-body">
     170                                    <img
     171                                        // loading gif
     172                                        src={logos[jobAd.recruiterId]}
     173                                        alt=""
     174                                        width={100} height={100}
     175                                    />
    148176                                    <h5 className="card-title">{jobAd.title}</h5>
    149177                                    <span>{jobAd.industry} • <span style={{
Note: See TracChangeset for help on using the changeset viewer.