diff --git a/.circleci/config.yml b/.circleci/config.yml index bdd7e19122..150ff555a7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -297,7 +297,7 @@ workflows: filters: branches: only: - - free + - gig-apply-restrict # This is stage env for production QA releases - "build-prod-staging": context : org-global diff --git a/src/server/services/recruitCRM.js b/src/server/services/recruitCRM.js index 10c9c1f97e..c352dd0dc5 100644 --- a/src/server/services/recruitCRM.js +++ b/src/server/services/recruitCRM.js @@ -308,15 +308,29 @@ export default class RecruitCRMService { error: true, status: candidateResponse.status, url: `${this.private.baseUrl}/v1/candidates/search?email=${form.email}`, - errObj: await candidateResponse.json(), + errorObj: await candidateResponse.json(), }; notifyKirilAndNick(error); return res.send(error); } let candidateData = await candidateResponse.json(); if (candidateData.data) { - // Candidate exists we will update profile fields - // otherwise we create it + // Candidate exists in recruitCRM + // We will update profile fields, otherwise we create new candidate below + // Check if candidate is placed in gig currently + const candStatusIndex = _.findIndex( + candidateData.data[0].custom_fields, { field_id: 12 }, + ); + if (candStatusIndex !== -1 && candidateData.data[0].custom_fields[candStatusIndex].value === 'Placed') { + // reject application + return res.send({ + error: true, + errorObj: { + notAllowed: true, + message: 'Apologies, you are not allowed to apply to gigs if you are already placed on a gig.', + }, + }); + } candidateSlug = candidateData.data[0].slug; const fieldIndexProfile = _.findIndex( candidateData.data[0].custom_fields, { field_id: 14 }, @@ -345,7 +359,7 @@ export default class RecruitCRMService { status: workCandidateResponse.status, url: `${this.private.baseUrl}/v1/candidates${candidateSlug ? `/${candidateSlug}` : ''}`, form, - errObj: await workCandidateResponse.json(), + errorObj: await workCandidateResponse.json(), }; notifyKirilAndNick(error); return res.send(error); @@ -371,7 +385,7 @@ export default class RecruitCRMService { fileData, file, formHeaders, - errObj: await fileCandidateResponse.json(), + errorObj: await fileCandidateResponse.json(), }; notifyKirilAndNick(error); return res.send(error); @@ -399,7 +413,7 @@ export default class RecruitCRMService { url: `${this.private.baseUrl}/v1/candidates/${candidateData.slug}/assign?job_slug=${id}`, form, candidateData, - errObj, + errorObj: errObj, }; notifyKirilAndNick(error); return res.send(error); @@ -423,7 +437,7 @@ export default class RecruitCRMService { status: hireStageResponse.status, url: `$${this.private.baseUrl}/v1/candidates/${candidateData.slug}/hiring-stages/${id}`, form, - errObj: await hireStageResponse.json(), + errorObj: await hireStageResponse.json(), }; notifyKirilAndNick(error); return res.send(error); diff --git a/src/shared/components/Gigs/GigApply/index.jsx b/src/shared/components/Gigs/GigApply/index.jsx index 9da7f27177..c7ef512a77 100644 --- a/src/shared/components/Gigs/GigApply/index.jsx +++ b/src/shared/components/Gigs/GigApply/index.jsx @@ -29,6 +29,7 @@ export default function GigApply(props) { } = props; const retUrl = window.location.href; const duration = getCustomField(job.custom_fields, 'Duration'); + const isPlaced = _.find(_.isEmpty(recruitProfile) ? [] : recruitProfile.custom_fields, { field_id: 12 }); return user ? (
@@ -45,10 +46,24 @@ export default function GigApply(props) {

{job.name}

GIG DETAILS
+ { + isPlaced && isPlaced.value === 'Placed' ? ( +
+ +

One Gig Limit!

+ +

Apologies, you are not allowed to apply to gigs if you are already placed on a gig.

You can however refer a friend to this gig and receive $500 if they get placed in that gig. To do that, you can enter their email on the right side of the Gigs Description page.

If you have any questions or feel this is an error, please email gigwork@topcoder.com.

+
+
+ Back To Gig +
+
+ ) : null + } { application ? (
- { application.error ? : bigCheckmark OK } + { application.error ? : bigCheckmark OK}

{application.error ? 'OOPS!' : 'APPLICATION SUBMITTED'}

{ application.error ? ( @@ -58,8 +73,16 @@ export default function GigApply(props) {

{application.errorObj.message || JSON.stringify(application.errorObj)}

) : null } -

Looks like there is a problem on our end. Please try again.
If this persists please contact support@topcoder.com.

-

Please send us an email at gigwork@topcoder.com with the subject ‘Gig Error’
and paste the URL for the gig you are attempting to apply for so that we know of your interest.

+ { + application.errorObj && application.errorObj.notAllowed ? ( +

If you have any questions or feel this is an error, please email gigwork@topcoder.com.

+ ) : ( + +

Looks like there is a problem on our end. Please try again.
If this persists please contact support@topcoder.com.

+

Please send us an email at gigwork@topcoder.com with the subject ‘Gig Error’
and paste the URL for the gig you are attempting to apply for so that we know of your interest.

+
+ ) + } ) : (

We will contact you via email if it seems like a fit!

@@ -69,15 +92,19 @@ export default function GigApply(props) { { application.error ? ( - { - e.preventDefault(); - window.location.reload(); - }} - >APPLY AGAIN - + { + !application.errorObj.notAllowed ? ( + { + e.preventDefault(); + window.location.reload(); + }} + >APPLY AGAIN + + ) : null + } VIEW OTHER GIGS ) : ( @@ -97,18 +124,18 @@ export default function GigApply(props) { ) : null } { - !application && !applying ? ( + !application && !applying && (!isPlaced || isPlaced.value !== 'Placed') ? (
{!_.isEmpty(recruitProfile) - && ( -
-
It looks like you have applied to a gig previously. Perfect!
-

We have most of your information. Is there anything you would like to update to your Gig Work Profile?

-
- )} + && ( +
+
It looks like you have applied to a gig previously. Perfect!
+

We have most of your information. Is there anything you would like to update to your Gig Work Profile?

+
+ )}

PERSONAL INFORMATION

{_.isEmpty(recruitProfile) - &&

Welcome to Topcoder Gigs! We’d like to get to know you.

} + &&

Welcome to Topcoder Gigs! We’d like to get to know you.

}
{_.isEmpty(recruitProfile) &&

TOPCODER INFORMATION

} {_.isEmpty(recruitProfile) && ( -
-
- onFormInputChange('handle', val)} - errorMsg={formErrors.handle} - value={formData.handle} - readonly - /> - onFormInputChange('tcProfileLink', val)} - errorMsg={formErrors.tcProfileLink} - value={formData.handle ? `https://topcoder.com/members/${formData.handle}` : null} - readonly - /> +
+
+ onFormInputChange('handle', val)} + errorMsg={formErrors.handle} + value={formData.handle} + readonly + /> + onFormInputChange('tcProfileLink', val)} + errorMsg={formErrors.tcProfileLink} + value={formData.handle ? `https://topcoder.com/members/${formData.handle}` : null} + readonly + /> +
-
)}

SHARE YOUR WEEKLY PAY EXPECTATIONS

@@ -236,14 +263,14 @@ export default function GigApply(props) {

FINAL QUESTIONS

{_.isEmpty(recruitProfile) && ( - onFormInputChange('reffereal', val)} - errorMsg={formErrors.reffereal} - options={formData.reffereal} - required - /> + onFormInputChange('reffereal', val)} + errorMsg={formErrors.reffereal} + options={formData.reffereal} + required + /> )}

Are you able to work during the specified timezone? ({`${getCustomField(job.custom_fields, 'Timezone')}`}) *

@@ -283,7 +310,7 @@ export default function GigApply(props) {
) : null - } + }
) }