Skip to content

Commit 0a9e8c8

Browse files
committed
#4891 custom tweeks
1 parent 7641323 commit 0a9e8c8

File tree

3 files changed

+56
-12
lines changed

3 files changed

+56
-12
lines changed

src/server/services/recruitCRM.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,17 @@ export default class RecruitCRMService {
210210
// Candidate exists we will update profile fields
211211
// otherwise we create it
212212
candidateSlug = candidateData.data[0].slug;
213+
const fieldIndexProfile = _.findIndex(
214+
candidateData.data[0].custom_fields, { field_id: 14 },
215+
);
216+
const fieldIndexForm = _.findIndex(form.custom_fields, { field_id: 14 });
217+
if (fieldIndexProfile !== -1 && fieldIndexForm !== -1) {
218+
form.custom_fields[fieldIndexForm].value += `;${candidateData.data[0].custom_fields[fieldIndexProfile].value}`;
219+
if (form.custom_fields[fieldIndexForm].value.length > 2000) {
220+
form.custom_fields[fieldIndexForm].value = form.custom_fields[
221+
fieldIndexForm].value.slice(0, 2000);
222+
}
223+
}
213224
}
214225
// Create/update candidate profile
215226
const workCandidateResponse = await fetch(`${this.private.baseUrl}/v1/candidates${candidateSlug ? `/${candidateSlug}` : ''}`, {
@@ -218,7 +229,7 @@ export default class RecruitCRMService {
218229
'Content-Type': 'application/json',
219230
Authorization: this.private.authorization,
220231
},
221-
body: body.form,
232+
body: JSON.stringify(form),
222233
});
223234
if (workCandidateResponse.status >= 400) {
224235
return res.send({

src/shared/actions/recruitCRM.js

+22-6
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,27 @@ async function getJobDone(id) {
4444
/**
4545
* Apply for Job init
4646
*/
47-
function applyForJobInit(id, payload) {
48-
return { id, payload };
47+
function applyForJobInit(job, payload) {
48+
return { id: job.slug, payload };
4949
}
5050

5151
/**
5252
* Helper utitlity
53+
* @param {object} joib The job object
5354
* @param {object} payload The apply form payload
5455
*/
55-
function normalizeRecruitPayload(payload) {
56+
function normalizeRecruitPayload(job, payload) {
57+
const perJob = [
58+
`${job.name} ->`,
59+
`Pay Expectation: ${payload.payExpectation}`,
60+
`Date Available: ${new Date(payload.availFrom).toDateString()}`,
61+
`Heard About Gig: ${payload.reffereal}`,
62+
`Why fit: ${payload.whyFit}`,
63+
`Availability Per Week: ${payload.timeAvailability.filter(s => s.checked).map(s => s.label).join(',')}`,
64+
`Able to work during timezone? ${payload.timezoneConfirm.filter(s => s.value).map(s => s.label).join(',')}`,
65+
`Am I ok to work the duration? ${payload.durationConfirm.filter(s => s.value).map(s => s.label).join(',')}`,
66+
`Notes: ${payload.notes}`,
67+
];
5668
return {
5769
last_name: payload.lname,
5870
first_name: payload.fname,
@@ -80,6 +92,10 @@ function normalizeRecruitPayload(payload) {
8092
field_id: 3,
8193
value: payload.whyFit || '',
8294
},
95+
{
96+
field_id: 14,
97+
value: perJob.join(','),
98+
},
8399
],
84100
resume: payload.fileCV,
85101
};
@@ -88,12 +104,12 @@ function normalizeRecruitPayload(payload) {
88104
/**
89105
* Apply for Job done
90106
*/
91-
async function applyForJobDone(id, payload) {
107+
async function applyForJobDone(job, payload) {
92108
const ss = new Service();
93-
const res = await ss.applyForJob(id, normalizeRecruitPayload(payload));
109+
const res = await ss.applyForJob(job.slug, normalizeRecruitPayload(job, payload));
94110

95111
return {
96-
id,
112+
id: job.slug,
97113
data: res,
98114
};
99115
}

src/shared/containers/Gigs/RecruitCRMJobApply.jsx

+22-5
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class RecruitCRMJobApplyContainer extends React.Component {
6565
onApplyClick() {
6666
const { applyForJob, job } = this.props;
6767
const { formData } = this.state;
68-
applyForJob(job.slug, formData);
68+
applyForJob(job, formData);
6969
}
7070

7171
validateForm() {
@@ -76,10 +76,27 @@ class RecruitCRMJobApplyContainer extends React.Component {
7676
'fname', 'lname', 'city', 'reffereal', 'phone', 'email',
7777
];
7878
// check required text fields for value
79+
// check min/max lengths
7980
_.each(requiredTextFields, (key) => {
8081
if (!formData[key] || !_.trim(formData[key])) formErrors[key] = 'Required field';
8182
else if (formData[key] && _.trim(formData[key]).length < 2) formErrors[key] = 'Must be at least 2 characters';
82-
else delete formErrors[key];
83+
else if (formData[key] && _.trim(formData[key]).length > 2) {
84+
switch (key) {
85+
case 'reffereal':
86+
if (_.trim(formData[key]).length > 2000) formErrors[key] = 'Must be max 2000 characters';
87+
else delete formErrors[key];
88+
break;
89+
case 'city':
90+
case 'phone':
91+
if (_.trim(formData[key]).length > 50) formErrors[key] = 'Must be max 50 characters';
92+
else delete formErrors[key];
93+
break;
94+
default:
95+
if (_.trim(formData[key]).length > 40) formErrors[key] = 'Must be max 40 characters';
96+
else delete formErrors[key];
97+
break;
98+
}
99+
} else delete formErrors[key];
83100
});
84101
// check for selected country
85102
if (!_.find(formData.country, { selected: true })) formErrors.country = 'Please, select your country';
@@ -175,9 +192,9 @@ function mapStateToProps(state, ownProps) {
175192
function mapDispatchToActions(dispatch) {
176193
const a = actions.recruit;
177194
return {
178-
applyForJob: (id, payload) => {
179-
dispatch(a.applyForJobInit(id, payload));
180-
dispatch(a.applyForJobDone(id, payload));
195+
applyForJob: (job, payload) => {
196+
dispatch(a.applyForJobInit(job, payload));
197+
dispatch(a.applyForJobDone(job, payload));
181198
},
182199
};
183200
}

0 commit comments

Comments
 (0)