From 64286a67722397cd48e926deb836c471f2267869 Mon Sep 17 00:00:00 2001 From: Kiril Kartunov Date: Mon, 10 May 2021 12:53:04 +0300 Subject: [PATCH 1/4] Implement #5509 --- src/server/services/recruitCRM.js | 28 +++- src/shared/components/Gigs/GigApply/index.jsx | 123 +++++++++++------- 2 files changed, 96 insertions(+), 55 deletions(-) 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..e3b935a3ee 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' ? ( +
+ +

OOPS!

+ +

Apologies, you are not allowed to apply to gigs if you are already placed on a gig.
If you have any questions or feel this is an error, please email gigwork@topcoder.com.

+
+ +
+ ) : 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 - } + }
) } From 79f8f87d3773e88a62bcb1ac1b5057e30d1339ae Mon Sep 17 00:00:00 2001 From: Kiril Kartunov Date: Tue, 11 May 2021 11:55:22 +0300 Subject: [PATCH 2/4] Final tweaks #5509 --- src/shared/components/Gigs/GigApply/index.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/shared/components/Gigs/GigApply/index.jsx b/src/shared/components/Gigs/GigApply/index.jsx index e3b935a3ee..c7ef512a77 100644 --- a/src/shared/components/Gigs/GigApply/index.jsx +++ b/src/shared/components/Gigs/GigApply/index.jsx @@ -50,12 +50,12 @@ export default function GigApply(props) { isPlaced && isPlaced.value === 'Placed' ? (
-

OOPS!

+

One Gig Limit!

-

Apologies, you are not allowed to apply to gigs if you are already placed on a gig.
If you have any questions or feel this is an error, please email gigwork@topcoder.com.

+

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.

- GO TO GIGS LIST + Back To Gig
) : null From b681ff515f3ad270631e37c932ac3834e10404f7 Mon Sep 17 00:00:00 2001 From: Kiril Kartunov Date: Tue, 11 May 2021 11:56:11 +0300 Subject: [PATCH 3/4] ci: on test --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index bdd7e19122..e5c06da98e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -283,7 +283,7 @@ workflows: filters: branches: only: - - free + - gig-apply-restrict # This is alternate dev env for parallel testing - "build-qa": context : org-global From f696f4d18a3ea3a712b25e07bd350969f322d736 Mon Sep 17 00:00:00 2001 From: Kiril Kartunov Date: Tue, 11 May 2021 12:30:08 +0300 Subject: [PATCH 4/4] ci: on beta --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e5c06da98e..150ff555a7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -283,7 +283,7 @@ workflows: filters: branches: only: - - gig-apply-restrict + - free # This is alternate dev env for parallel testing - "build-qa": context : org-global @@ -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