1 | import axios from "../../axios/axiosInstance";
|
---|
2 | import {SET_PROFILE_PIC_URL} from "../actionTypes";
|
---|
3 |
|
---|
4 | export const JobSeekerActions = {
|
---|
5 |
|
---|
6 | submitProfilePic: (formData, callback) => {
|
---|
7 | let jobSeekerId = formData.get("jobSeekerId");
|
---|
8 | let profilePicFile = formData.get("profilePicFile")
|
---|
9 | return dispatch => {
|
---|
10 | axios.post("/job-seeker/submit-profile-pic", formData, {
|
---|
11 | headers: {
|
---|
12 | 'Content-Type': 'multipart/form-data'
|
---|
13 | }
|
---|
14 | })
|
---|
15 | .then(response => {
|
---|
16 | const blob = new Blob([profilePicFile])
|
---|
17 | const profilePicUrl = window.URL.createObjectURL(blob);
|
---|
18 | dispatch({
|
---|
19 | type: SET_PROFILE_PIC_URL,
|
---|
20 | payload: {jobSeekerId, profilePicUrl}
|
---|
21 | })
|
---|
22 | callback(true, response)
|
---|
23 | }).catch(error => {
|
---|
24 | callback(false, error)
|
---|
25 | })
|
---|
26 | }
|
---|
27 | },
|
---|
28 |
|
---|
29 | downloadProfilePic: (jobSeekerId, callback) => {
|
---|
30 | return dispatch => {
|
---|
31 | return axios.get("/job-seeker/" + jobSeekerId + "/download-profile-pic", {responseType: "blob"})
|
---|
32 | .then(response => {
|
---|
33 | const blob = new Blob([response.data])
|
---|
34 | const profilePicUrl = window.URL.createObjectURL(blob);
|
---|
35 | dispatch({
|
---|
36 | type: SET_PROFILE_PIC_URL,
|
---|
37 | payload: {jobSeekerId, profilePicUrl}
|
---|
38 | });
|
---|
39 | callback(true, profilePicUrl)
|
---|
40 | }).catch(error => {
|
---|
41 | callback(false, error)
|
---|
42 | })
|
---|
43 | }
|
---|
44 | },
|
---|
45 |
|
---|
46 | fetchJobSeekerEditDetailsById: (id, callback) => {
|
---|
47 | return dispatch => {
|
---|
48 | return axios.get("/job-seeker/"+id+"/edit-info")
|
---|
49 | .then(response => {
|
---|
50 | callback(true, response)
|
---|
51 | }).catch(error => {
|
---|
52 | callback(false, error)
|
---|
53 | })
|
---|
54 | }
|
---|
55 | },
|
---|
56 |
|
---|
57 | editJobSeekerDetailsById: (data, id, callback) => {
|
---|
58 | return dispatch => {
|
---|
59 | return axios.post("/job-seeker/"+id+"/edit-info", data)
|
---|
60 | .then(response => {
|
---|
61 | callback(true, response)
|
---|
62 | }).catch(error => {
|
---|
63 | callback(false, error)
|
---|
64 | })
|
---|
65 | }
|
---|
66 | }
|
---|
67 | } |
---|