source: jobvista-frontend/src/redux/actions/jobAdvertisementActions.js@ b248810

main
Last change on this file since b248810 was 28b3398, checked in by 223021 <daniel.ilievski.2@…>, 3 weeks ago

Implemented job application functionality, added job advertisement filtering and replaced text areas with editors

  • Property mode set to 100644
File size: 4.1 KB
Line 
1import axios from "../../axios/axiosInstance";
2import {
3 ADD_JOB_ADVERTISEMENT,
4 CURRENT_USER, DELETE_JOB_ADVERTISEMENT, EDIT_JOB_ADVERTISEMENT,
5 FETCH_JOB_ADVERTISEMENTS,
6 FETCH_JOB_ADVERTISEMENTS_BY_RECRUITER, FILTER_JOB_ADVERTISEMENTS
7} from "../actionTypes";
8
9export const JobAdvertisementActions = {
10 addJobAdvertisement: (jobAdvertisement, callback) => {
11 return dispatch => {
12 axios.post("/job-advertisements/add", jobAdvertisement, {
13 headers: {
14 'Content-Type': 'application/json'
15 },
16 })
17 .then(response => {
18 dispatch({
19 type: ADD_JOB_ADVERTISEMENT,
20 jobAdvertisement: response.data
21 })
22 callback(true, response)
23 }).catch((error) => {
24 callback(false, error)
25 })
26 }
27 },
28 editJobAdvertisement: (jobAdvertisement, id, callback) => {
29 return dispatch => {
30 axios.put("/job-advertisements/edit/" + id, jobAdvertisement)
31 .then(response => {
32 dispatch({
33 type: EDIT_JOB_ADVERTISEMENT,
34 jobAdvertisement: response.data
35 })
36 callback(true, response)
37 }).catch((error) => {
38 callback(false, error)
39 })
40 }
41 },
42 deleteJobAdvertisement: (id, callback) => {
43 return dispatch => {
44 axios.delete("/job-advertisements/delete/" + id)
45 .then(response => {
46 dispatch({
47 type: DELETE_JOB_ADVERTISEMENT,
48 id: id
49 })
50 callback(true)
51 }).catch(error => {
52 callback(false, error)
53 })
54
55 }
56 },
57 fetchJobAdvertisementById: (id, callback) => {
58 axios.get("/job-advertisements/" + id)
59 .then(response => {
60 callback(true, response)
61 }).catch(error => {
62 callback(false, error)
63 })
64 },
65
66 fetchJobAdvertisements: (callback) => {
67 return dispatch => {
68 axios.get("/job-advertisements/all")
69 .then(response => {
70 dispatch({
71 type: FETCH_JOB_ADVERTISEMENTS,
72 jobAdvertisements: response.data,
73 })
74 callback(true, response)
75 }).catch((error) => {
76 callback(false, error)
77 })
78 }
79 },
80 filterJobAdvertisements: (filter, callback) => {
81 axios.post("/job-advertisements/filtered", filter)
82 .then(response => {
83 callback(true, response)
84 }).catch((error) => {
85 callback(false, error) })
86
87 },
88
89 fetchJobAdvertisementsByRecruiter: (callback) => {
90 return dispatch => {
91 let currentUser = JSON.parse(localStorage.getItem(CURRENT_USER));
92 axios.get("/job-advertisements/recruiter/" + currentUser.id)
93 .then(response => {
94 dispatch({
95 type: FETCH_JOB_ADVERTISEMENTS_BY_RECRUITER,
96 jobAdvertisementsByRecruiter: response.data,
97 })
98 callback(true, response)
99 }).catch((error) => {
100 callback(false, error)
101 })
102 }
103 },
104
105 filterJobAdvertisementsByRecruiter: (filter, callback) => {
106
107 let currentUser = JSON.parse(localStorage.getItem(CURRENT_USER));
108 axios.post("/job-advertisements/recruiter/" + currentUser.id + "/filtered", filter)
109 .then(response => {
110 callback(true, response)
111 }).catch((error) => {
112 callback(false, error)
113 })
114
115 },
116
117 fetchRecruiterDetailsById: (id, callback) => {
118 axios.get("/recruiter/info/" + id)
119 .then(response => {
120 callback(true, response)
121 }).catch(error => {
122 callback(false, error)
123 })
124 }
125}
Note: See TracBrowser for help on using the repository browser.