Ignore:
Timestamp:
06/20/24 11:57:13 (11 days ago)
Author:
223021 <daniel.ilievski.2@…>
Branches:
main
Children:
0f0add0
Parents:
befb988
Message:

Did more refactoring

Location:
jobvista-frontend/src/redux
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • jobvista-frontend/src/redux/actions/applicationActions.js

    rbefb988 r08f82ec  
    1010    submitApplication: (application, callback) => {
    1111        return dispatch => {
    12             axios.post("/job-advertisements/apply", application, {
     12            axios.post("/applications/submit", application, {
    1313                headers: {
    1414                    'Content-Type': 'multipart/form-data'
     
    2626            })
    2727        }
    28 
    2928    },
    3029    updateApplicationStatus: (id, status, callback) => {
    3130        console.log(status)
    32       return dispatch => {
    33             // TO DO: REFACTOR
    34           axios.post("/applications/" + id + "/update", {
    35               id: id,
    36               status: status
    37           })
    38               .then(response => {
    39                   dispatch({
    40                       type: UPDATE_APPLICATION_STATUS,
    41                       application: response.data,
    42                   })
    43                   callback(true, response)
    44               }).catch(error => {
    45               callback(false, error)
    46           })
    47       }
     31        return dispatch => {
     32            axios.post("/applications/" + id + "/update", {
     33                id: id,
     34                status: status
     35            })
     36                .then(response => {
     37                    dispatch({
     38                        type: UPDATE_APPLICATION_STATUS,
     39                        application: response.data,
     40                    })
     41                    callback(true, response)
     42                }).catch(error => {
     43                callback(false, error)
     44            })
     45        }
    4846    },
    4947    fetchApplicationsByJobSeeker: (jobSeekerId, callback) => {
    50       return dispatch => {
    51           axios.get("/my-applications/" + jobSeekerId)
    52               .then(response => {
    53                   dispatch({
    54                       type: FETCH_APPLICATIONS_BY_JOB_SEEKER_ID,
    55                       applicationsByJobSeeker: response.data
    56                   })
    57                   callback(true, response)
    58               }).catch(error => {
    59                   callback(false, error)
    60           })
    61       }
     48        return dispatch => {
     49            axios.get("/my-applications/" + jobSeekerId)
     50                .then(response => {
     51                    dispatch({
     52                        type: FETCH_APPLICATIONS_BY_JOB_SEEKER_ID,
     53                        applicationsByJobSeeker: response.data
     54                    })
     55                    callback(true, response)
     56                }).catch(error => {
     57                callback(false, error)
     58            })
     59        }
    6260    },
    6361
     
    7775        }
    7876    },
    79     downloadResume: (fileName, callback) => {
    80         return dispatch => {
    81             return axios.get("/resume/" + fileName, {responseType: "blob"})
    82                 .then(response => {
    83                     const blob = new Blob([response.data], { type: 'application/pdf' });
    84                     const url = window.URL.createObjectURL(blob);
    85                     callback(true, url);
    86                 })
     77    downloadResume: (id, callback) => {
     78        return axios.get("/applications/" + id + "/download-resume", {responseType: "blob"})
     79            .then(response => {
     80                const blob = new Blob([response.data], {type: 'application/pdf'});
     81                const url = window.URL.createObjectURL(blob);
     82                callback(true, url);
     83            })
     84            .catch(error => {
     85                callback(false, error)
     86            })
    8787
    88                 .catch(error => {
    89                     callback(false, error)
    90                 })
    91         }
    9288    }
    9389}
  • jobvista-frontend/src/redux/actions/jobAdvertisementActions.js

    rbefb988 r08f82ec  
    1010    addJobAdvertisement: (jobAdvertisement, callback) => {
    1111        return dispatch => {
    12             axios.post("/job-advertisements/add",  jobAdvertisement, {
    13                 headers: {
    14                     'Content-Type': 'application/json'
    15                 },
    16             })
     12            axios.post("/job-advertisements/add", jobAdvertisement)
    1713                .then(response => {
    1814                    dispatch({
     
    2016                        jobAdvertisement: response.data
    2117                    })
    22                     callback(true, response)
     18                    callback(true)
    2319                }).catch((error) => {
    24                 callback(false, error)
     20                console.error(error)
     21                callback(false)
    2522            })
    2623        }
     
    3431                        jobAdvertisement: response.data
    3532                    })
    36                     callback(true, response)
     33                    callback(true)
    3734                }).catch((error) => {
    38                 callback(false, error)
     35                console.error(error)
     36                callback(false)
    3937            })
    4038        }
     
    5048                    callback(true)
    5149                }).catch(error => {
    52                 callback(false, error)
     50                console.error(error)
     51                callback(false)
    5352            })
    5453
     
    8382                callback(true, response)
    8483            }).catch((error) => {
    85             callback(false, error)        })
     84            callback(false, error)
     85        })
    8686
    8787    },
     
    9696                        jobAdvertisementsByRecruiter: response.data,
    9797                    })
     98                    callback(true, response)
     99                }).catch((error) => {
     100                callback(false, error)
     101            })
     102        }
     103    },
     104
     105    fetchJobAdvertisementsByRecruiterProfile: (recruiterId, callback) => {
     106        return dispatch => {
     107            let currentUser = JSON.parse(localStorage.getItem(CURRENT_USER));
     108            axios.get("/job-advertisements/recruiter/" + recruiterId)
     109                .then(response => {
    98110                    callback(true, response)
    99111                }).catch((error) => {
     
    116128
    117129    fetchRecruiterDetailsById: (id, callback) => {
    118         axios.get("/recruiter/"+id+"/info")
     130        axios.get("/recruiter/" + id + "/info")
    119131            .then(response => {
    120132                callback(true, response)
Note: See TracChangeset for help on using the changeset viewer.