@@ -58,47 +58,45 @@ function normalizeRecruitPayload(job, payload) {
5858 const perJob = [
5959 `${ job . name } ->` ,
6060 `Pay Expectation: ${ payload . payExpectation } ` ,
61- `Date Available: ${ new Date ( payload . availFrom ) . toDateString ( ) } ` ,
62- `Heard About Gig: ${ payload . reffereal } ` ,
63- `Why fit: ${ payload . whyFit } ` ,
6461 `Able to work during timezone? ${ payload . timezoneConfirm . filter ( s => s . value ) . map ( ( ) => getCustomField ( job . custom_fields , 'Timezone' ) ) . join ( ',' ) } ` ,
65- `Am I ok to work the duration? ${ payload . durationConfirm . filter ( s => s . value ) . map ( s => s . label ) . join ( ',' ) } ` ,
66- `Notes: ${ payload . notes } ` ,
62+ `Am I ok to work the duration? ${ payload . durationConfirm . filter ( s => s . value ) . map ( ( ) => getCustomField ( job . custom_fields , 'Duration' ) ) . join ( ',' ) } ` ,
6763 ] ;
68- return {
64+ const referral = _ . find ( payload . reffereal , { selected : true } ) ;
65+ const normalized = {
6966 last_name : payload . lname ,
7067 first_name : payload . fname ,
7168 email : payload . email ,
7269 contact_number : payload . phone ,
7370 city : payload . city ,
7471 locality : _ . find ( payload . country , { selected : true } ) . label ,
75- available_from : payload . availFrom ,
7672 salary_expectation : payload . payExpectation ,
7773 skill : payload . skills . filter ( s => s . selected ) . map ( s => s . label ) . join ( ',' ) ,
7874 custom_fields : [
79- {
80- field_id : 13 ,
81- value : payload . reffereal || '' ,
82- } ,
8375 {
8476 field_id : 1 ,
85- value : payload . tcProfileLink || ( payload . handle ? `topcoder.com/members/${ payload . handle } ` : '' ) ,
77+ value : payload . tcProfileLink || ( payload . handle ? `https:// topcoder.com/members/${ payload . handle } ` : '' ) ,
8678 } ,
8779 {
8880 field_id : 2 ,
8981 value : payload . handle || '' ,
9082 } ,
91- {
92- field_id : 3 ,
93- value : payload . whyFit || '' ,
94- } ,
9583 {
9684 field_id : 14 ,
9785 value : perJob . join ( ',' ) ,
9886 } ,
9987 ] ,
100- resume : payload . fileCV ,
10188 } ;
89+ if ( referral ) {
90+ normalized . custom_fields . push ( {
91+ field_id : 13 ,
92+ value : referral . label ,
93+ } ) ;
94+ }
95+ if ( payload . fileCV ) {
96+ normalized . resume = payload . fileCV ;
97+ }
98+
99+ return normalized ;
102100}
103101
104102/**
@@ -124,6 +122,37 @@ async function applyForJobDone(job, payload) {
124122 }
125123}
126124
125+ /**
126+ * Search for cnadidate in recruit
127+ */
128+ function searchCandidatesInit ( email ) {
129+ return { email } ;
130+ }
131+
132+ /**
133+ * Search for cnadidate in recruit and get profile if available
134+ * @param {string } email the email to search
135+ */
136+ async function searchCandidatesDone ( email ) {
137+ const ss = new Service ( ) ;
138+ try {
139+ const res = await ss . searchCandidates ( email ) ;
140+
141+ return {
142+ email,
143+ data : res ,
144+ } ;
145+ } catch ( error ) {
146+ return {
147+ email,
148+ data : {
149+ error : true ,
150+ errorObj : error ,
151+ } ,
152+ } ;
153+ }
154+ }
155+
127156export default redux . createActions ( {
128157 RECRUIT : {
129158 GET_JOBS_INIT : getJobsInit ,
@@ -132,5 +161,7 @@ export default redux.createActions({
132161 GET_JOB_DONE : getJobDone ,
133162 APPLY_FOR_JOB_INIT : applyForJobInit ,
134163 APPLY_FOR_JOB_DONE : applyForJobDone ,
164+ SEARCH_CANDIDATES_INIT : searchCandidatesInit ,
165+ SEARCH_CANDIDATES_DONE : searchCandidatesDone ,
135166 } ,
136167} ) ;
0 commit comments