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

Did more refactoring

File:
1 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}
Note: See TracChangeset for help on using the changeset viewer.