Skip to content

Commit f79c12a

Browse files
committed
init code for general referrals
1 parent 0d78f13 commit f79c12a

File tree

9 files changed

+126
-22
lines changed

9 files changed

+126
-22
lines changed

config/default.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ module.exports = {
263263
GROWSURF_COOKIE_SETTINGS: {
264264
secure: true,
265265
domain: '',
266-
expires: 7, // days
266+
expires: 30, // days
267267
},
268268

269269
GSHEETS_API_KEY: 'AIzaSyBRdKySN5JNCb2H6ZxJdTTvp3cWU51jiOQ',

src/server/services/recruitCRM.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ export default class RecruitCRMService {
274274
if (referralCookie) referralCookie = JSON.parse(referralCookie);
275275
try {
276276
// referral tracking via growsurf
277-
if (referralCookie && referralCookie.gigId === id) {
277+
if (referralCookie) {
278278
const gs = new GrowsurfService();
279279
const tcHandle = _.findIndex(form.custom_fields, { field_id: 2 });
280280
const growRes = await gs.addParticipant(JSON.stringify({
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/* eslint-disable max-len */
2+
/**
3+
* Connects the Redux store to the GigsPages component.
4+
*/
5+
import React, { useState } from 'react';
6+
import PT from 'prop-types';
7+
import _ from 'lodash';
8+
import { PrimaryButton } from 'topcoder-react-ui-kit';
9+
import tc from 'components/buttons/themed/tc.scss';
10+
import ReferralModal from '../ReferralModal';
11+
import defautlStyle from './style.scss';
12+
13+
/** Themes for buttons
14+
* those overwrite PrimaryButton style to match achieve various styles.
15+
* Should implement pattern of classes.
16+
*/
17+
const buttonThemes = {
18+
tc,
19+
};
20+
21+
function ReferralCode(props) {
22+
const { profile } = props;
23+
const [loginModalOpen, setLoginModalOpen] = useState(false);
24+
return (
25+
<div className={defautlStyle.container}>
26+
<span className={defautlStyle.title}>Topcoder Referral Program:</span>
27+
{
28+
_.isEmpty(profile) ? (
29+
<React.Fragment>
30+
<span>Do you know someone who is perfect for a gig? You could earn $500 for referring them!</span>
31+
<PrimaryButton
32+
onClick={() => {
33+
setLoginModalOpen(true);
34+
}}
35+
theme={{
36+
button: buttonThemes.tc['primary-borderless-sm'],
37+
}}
38+
>
39+
REFFER A FRIEND
40+
</PrimaryButton>
41+
{
42+
loginModalOpen
43+
&& (
44+
<ReferralModal
45+
profile={profile}
46+
onCloseButton={() => setLoginModalOpen(false)}
47+
isReferrSucess={false}
48+
isReferrError={false}
49+
onReferralDone={() => {}}
50+
/>
51+
)
52+
}
53+
</React.Fragment>
54+
) : (
55+
<React.Fragment>
56+
<span>Your referral link:</span>
57+
</React.Fragment>
58+
)
59+
}
60+
</div>
61+
);
62+
}
63+
64+
ReferralCode.defaultProps = {
65+
profile: null,
66+
};
67+
68+
ReferralCode.propTypes = {
69+
profile: PT.shape(),
70+
};
71+
72+
export default ReferralCode;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
.container {
2+
display: flex;
3+
background-image: linear-gradient(97.21deg, #2984BD 0%, #0AB88A 100%);
4+
border-radius: 10px;
5+
width: 100%;
6+
max-width: 1280px;
7+
margin: 30px auto 0;
8+
align-items: center;
9+
padding: 13px 25px 11px;
10+
11+
.title {
12+
font-weight: bold;
13+
}
14+
15+
span {
16+
font-family: Roboto, sans-serif;
17+
font-size: 18px;
18+
color: #fff;
19+
line-height: 22px;
20+
margin-right: 5px;
21+
}
22+
23+
button {
24+
margin-left: 10px !important;
25+
&:hover {
26+
margin-left: 10px !important;
27+
}
28+
}
29+
}

src/shared/components/Gigs/ReferralModal/index.jsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable max-len */
12
/**
23
* The modal used for gig referral flow
34
*/
@@ -90,10 +91,9 @@ function ReferralModal({
9091
</div>
9192
) : (
9293
<div className={modalStyle.loginRequired}>
93-
<h3 className={modalStyle.title}>WARNING</h3>
94-
<p className={modalStyle.loginMsg}>You must be a Topcoder member to refer!</p>
94+
<h3 className={modalStyle.title}>REFERRAL PROGRAM</h3>
95+
<p className={modalStyle.loginMsg}>Please login to receive your referral code.</p>
9596
<div className={modalStyle.ctaButtons}>
96-
<Link to={HELP_INFO_LINK} className={buttonThemes.tc['primary-white-md']} openNewTab="true">FIND OUT MORE</Link>
9797
<PrimaryButton
9898
onClick={() => {
9999
window.location = `${config.URL.AUTH}/member?retUrl=${encodeURIComponent(retUrl)}`;
@@ -104,8 +104,9 @@ function ReferralModal({
104104
>
105105
LOGIN
106106
</PrimaryButton>
107+
<Link to={`${config.URL.AUTH}/member/registration?retUrl=${encodeURIComponent(retUrl)}&mode=signUp&utm_source=gig_listing`} className={buttonThemes.tc['primary-white-md']} openNewTab="true">REGISTER</Link>
107108
</div>
108-
<p className={modalStyle.regTxt}>Not a member? It is free to <a href={`${config.URL.AUTH}/member/registration?retUrl=${encodeURIComponent(retUrl)}&mode=signUp&utm_source=gig_listing`}>register</a>!</p>
109+
<p className={modalStyle.regTxt}>Find out how the referral program works <a href={HELP_INFO_LINK}>here</a>.</p>
109110
</div>
110111
)}
111112
</Modal>

src/shared/components/Gigs/ReferralModal/modal.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
}
2727

2828
.loginMsg {
29-
color: #ef476f;
29+
color: #2a2a2a;
3030
font-size: 24px;
3131
line-height: 36px;
3232
margin-bottom: 40px;

src/shared/containers/Gigs/RecruitCRMJobDetails.jsx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,11 @@ import GigDetails from 'components/Gigs/GigDetails';
1010
import PT from 'prop-types';
1111
import React from 'react';
1212
import { connect } from 'react-redux';
13-
import { getQuery } from 'utils/url';
1413
import { isValidEmail } from 'utils/tc';
1514
import { config } from 'topcoder-react-utils';
1615
import fetch from 'isomorphic-fetch';
1716
import RecruitCRMJobApply from './RecruitCRMJobApply';
1817

19-
const cookies = require('browser-cookies');
20-
2118
const PROXY_ENDPOINT = `${config.URL.COMMUNITY_APP}/api`;
2219

2320
class RecruitCRMJobDetailsContainer extends React.Component {
@@ -53,13 +50,6 @@ ${config.URL.BASE}${config.GIGS_PAGES_PATH}/${props.id}`,
5350
if (isEmpty(job)) {
5451
getJob(id);
5552
}
56-
const query = getQuery();
57-
if (query.referralId) {
58-
cookies.set(config.GROWSURF_COOKIE, JSON.stringify({
59-
referralId: query.referralId,
60-
gigId: id,
61-
}), config.GROWSURF_COOKIE_SETTINGS);
62-
}
6353
}
6454

6555
/**

src/shared/containers/Gigs/RecruitCRMJobs.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class RecruitCRMJobsContainer extends React.Component {
156156
if (loading) {
157157
return (
158158
<React.Fragment>
159-
<LoadingIndicator />;
159+
<LoadingIndicator />
160160
<p styleName="loading-text">Searching our database for the best gigs…</p>
161161
</React.Fragment>
162162
);

src/shared/containers/GigsPages.jsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import { OptimizelyProvider, createInstance } from '@optimizely/react-sdk';
1414
import { connect } from 'react-redux';
1515
import _ from 'lodash';
1616
import { v4 as uuidv4 } from 'uuid';
17+
import { getQuery } from 'utils/url';
18+
import ReferralCode from 'components/Gigs/ReferralCode';
1719

1820
const optimizelyClient = createInstance({
1921
sdkKey: config.OPTIMIZELY.SDK_KEY,
@@ -44,6 +46,13 @@ function GigsPagesContainer(props) {
4446
expires: 365, // days
4547
});
4648
}
49+
// check for referral code in the URL and set it to cookie
50+
const query = getQuery();
51+
if (query.referralId) {
52+
cookies.set(config.GROWSURF_COOKIE, JSON.stringify({
53+
referralId: query.referralId,
54+
}), config.GROWSURF_COOKIE_SETTINGS);
55+
}
4756
}
4857
const { id, type } = match.params;
4958
const isApply = `${config.GIGS_PAGES_PATH}/${id}/apply` === match.url;
@@ -76,10 +85,13 @@ window._chatlio = window._chatlio||[];
7685
}
7786
{
7887
!id && !type ? (
79-
<Viewport
80-
id="3X6GfJZl3eDU0m4joSJZpN"
81-
baseUrl={config.GIGS_PAGES_PATH}
82-
/>
88+
<React.Fragment>
89+
<ReferralCode profile={profile} />
90+
<Viewport
91+
id="3X6GfJZl3eDU0m4joSJZpN"
92+
baseUrl={config.GIGS_PAGES_PATH}
93+
/>
94+
</React.Fragment>
8395
) : null
8496
}
8597
<Footer />

0 commit comments

Comments
 (0)