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/redux/reducers
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • jobvista-frontend/src/redux/reducers/authReducer.js

    rb248810 rbefb988  
    33import {isExpired} from "react-jwt";
    44import {CURRENT_USER, SIGN_IN, SIGN_OUT, UPDATE_TOKEN} from "../actionTypes";
     5import {jwtDecode} from "jwt-decode";
    56
    67const initialState = {
     
    1314        case SIGN_IN:
    1415            localStorage.setItem(AUTH_TOKEN, action.payload.token);
    15             localStorage.setItem(CURRENT_USER, JSON.stringify(action.payload.user));
     16            //localStorage.setItem(CURRENT_USER, JSON.stringify(action.payload.user));
    1617            return {
    1718                ...state,
     
    2122        case UPDATE_TOKEN:
    2223            let token = action.payload;
     24            let decodedToken;
    2325            let currentUser = "";
     26            if(token !=null) {
     27                try {
     28                    decodedToken = jwtDecode(token);
     29                } catch (error) {
     30                    console.log("Failed to decode token: " + error)
     31                }
     32            }
     33
    2434            if(!isExpired(token)) {
    2535                localStorage.setItem(AUTH_TOKEN, token);
    26                 currentUser = JSON.parse(localStorage.getItem(CURRENT_USER));
     36                currentUser = {
     37                    name: decodedToken.name,
     38                    role: decodedToken.role,
     39                    access: decodedToken.access,
     40                    id: decodedToken.id
     41                };
    2742            } else {
    28                 localStorage.removeItem(CURRENT_USER);
     43                //localStorage.removeItem(CURRENT_USER);
    2944                localStorage.removeItem(AUTH_TOKEN);
    3045                currentUser = "";
     
    3752            };
    3853        case SIGN_OUT:
    39             localStorage.removeItem(CURRENT_USER);
     54            //localStorage.removeItem(CURRENT_USER);
    4055            localStorage.removeItem(AUTH_TOKEN);
    4156            return {
  • jobvista-frontend/src/redux/reducers/jobAdvertisementReducer.js

    rb248810 rbefb988  
    11import {
    22    ADD_JOB_ADVERTISEMENT,
    3     CURRENT_USER, DELETE_JOB_ADVERTISEMENT, EDIT_JOB_ADVERTISEMENT,
     3    CURRENT_USER,
     4    DELETE_JOB_ADVERTISEMENT,
     5    EDIT_JOB_ADVERTISEMENT,
    46    FETCH_JOB_ADVERTISEMENTS,
    5     FETCH_JOB_ADVERTISEMENTS_BY_RECRUITER, FILTER_JOB_ADVERTISEMENTS, FILTER_JOB_ADVERTISEMENTS_BY_RECRUITER
     7    FETCH_JOB_ADVERTISEMENTS_BY_RECRUITER,
     8    FILTER_JOB_ADVERTISEMENTS,
     9    FILTER_JOB_ADVERTISEMENTS_BY_RECRUITER,
     10    SET_LOGO_URL
    611} from "../actionTypes";
    712import {sortElementsBy} from "../../utils/utils";
Note: See TracChangeset for help on using the changeset viewer.