Ignore:
Timestamp:
06/10/24 22:34:32 (5 months ago)
Author:
223021 <daniel.ilievski.2@…>
Branches:
main
Children:
befb988
Parents:
28b3398
Message:

Added no access page for new recruiters and admin panel for granting access

File:
1 edited

Legend:

Unmodified
Added
Removed
  • jobvista-frontend/src/views/dashboard/Dashboard.js

    r28b3398 rb248810  
    44import {useEffect, useState} from "react";
    55import {JobAdvertisementActions} from "../../redux/actions/jobAdvertisementActions";
    6 import {formatRelativeTime, sortElementsByDateCreated} from "../../utils/utils";
     6import {formatRelativeTime, sortElementsBy} from "../../utils/utils";
    77import {dataRangeOptions, industryOptions, industryOptionsFilter, sortOptions} from "../selectOptions";
    88import Select from "react-select";
     
    1010import {Link} from "react-router-dom";
    1111import JobType from "../../enumerations/JobType";
     12import {AUTH_TOKEN} from "../../axios/axiosInstance";
     13import {jwtDecode} from "jwt-decode";
    1214
    13 export const Dashboard = () => {
     15export const Dashboard = (props) => {
    1416
    1517    const dispatch = useDispatch();
     
    1719    const [jobAdvertisements, setJobAdvertisements] = useState([]);
    1820    let jobAdvertisementsState = useSelector(state => state.jobAd.jobAdvertisements)
    19     const auth = useSelector(state => state.auth.currentUser);
     21    const auth = useSelector(state => state.auth);
    2022
    21     const [role, setRole] = useState("");
     23    // const [role, setRole] = useState("");
    2224    const [selectedSortOrder, setSelectedSortOrder] = useState("date_newest");
    2325    const [selectedIndustry, setSelectedIndustry] = useState("all");
     
    2527    const [dispatched, setDispatched] = useState(false)
    2628
    27     useEffect(() => {
    28         if (auth) {
    29             setRole(auth.role);
    30         }
    31     }, [auth]);
     29    // const [user, setUser] = useState(null);
     30    //
     31    // useEffect(() => {
     32    //     const token = localStorage.getItem(AUTH_TOKEN);
     33    //     if (token!=null) {
     34    //         try {
     35    //             const decodedToken = jwtDecode(token);
     36    //             setUser({
     37    //                 name: decodedToken.name,
     38    //                 role: decodedToken.role,
     39    //                 hasAccess: decodedToken.access,
     40    //             });
     41    //         } catch (error) {
     42    //             console.error('Failed to decode token', error);
     43    //         }
     44    //     }
     45    //     console.log(user)
     46    // }, [auth]);
     47
     48    // useEffect(() => {
     49    //     if (auth) {
     50    //         setRole(auth.role);
     51    //     }
     52    //     console.log(props)
     53    // }, [auth]);
    3254
    3355    useEffect(() => {
     
    3557            dispatch(JobAdvertisementActions.fetchJobAdvertisements((success, response) => {
    3658                if (success && response.data.length > 0) {
    37                     setJobAdvertisements(sortElementsByDateCreated(response.data))
     59                    setJobAdvertisements(sortElementsBy(response.data))
    3860                }
    3961                setDispatched(true)
     
    6284
    6385    return (
     86
    6487        <div className="container">
    6588            <div className="head-dashboard-box">
Note: See TracChangeset for help on using the changeset viewer.