source: jobvista-frontend/src/redux/actions/recruiterActions.js@ 4d97b63

main
Last change on this file since 4d97b63 was 08f82ec, checked in by 223021 <daniel.ilievski.2@…>, 5 months ago

Did more refactoring

  • Property mode set to 100644
File size: 2.3 KB
RevLine 
[08f82ec]1
2import axios from "../../axios/axiosInstance";
3import {SET_LOGO_URL} from "../actionTypes";
4export const RecruiterActions = {
5 submitLogo: (formData, callback) => {
6 let recruiterId = formData.get("recruiterId");
7 let logoFile = formData.get("logoFile")
8 return dispatch => {
9 axios.post("/recruiter/submit-logo", formData, {
10 headers: {
11 'Content-Type': 'multipart/form-data'
12 }
13 })
14 .then(response => {
15 const blob = new Blob([logoFile])
16 const logoUrl = window.URL.createObjectURL(blob);
17 dispatch({
18 type: SET_LOGO_URL,
19 payload: { recruiterId, logoUrl }
20 });
21 callback(true, response)
22 }).catch(error => {
23 callback(false, error)
24 })
25 }
26 },
27
28 downloadLogo: (recruiterId, callback) => {
29 return dispatch => {
30 return axios.get("/recruiter/" + recruiterId + "/download-logo", {responseType: "blob"})
31 .then(response => {
32 const blob = new Blob([response.data])
33 const logoUrl = window.URL.createObjectURL(blob);
34 dispatch({
35 type: SET_LOGO_URL,
36 payload: { recruiterId, logoUrl }
37 });
38 callback(true, logoUrl);
39 }).catch(error => {
40 callback(false, error)
41 })
42 }
43 },
44
45 fetchRecruiterEditDetailsById: (id, callback) => {
46 return dispatch => {
47 return axios.get("/recruiter/"+id+"/edit-info")
48 .then(response => {
49 callback(true, response)
50 }).catch(error => {
51 callback(false, error)
52 })
53 }
54 },
55
56 editRecruiterDetailsById: (data, id, callback) => {
57 return dispatch => {
58 return axios.post("/recruiter/"+id+"/edit-info", data)
59 .then(response => {
60 callback(true, response)
61 }).catch(error => {
62 callback(false, error)
63 })
64 }
65 }
66}
Note: See TracBrowser for help on using the repository browser.