Skip to content

Commit 9581f7e

Browse files
committed
Referral form updates
1 parent 2bfd397 commit 9581f7e

File tree

6 files changed

+47
-11
lines changed

6 files changed

+47
-11
lines changed

__tests__/shared/components/GUIKit/Textarea/__snapshots__/index.jsx.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ exports[`Default render 1`] = `
1010
id="textAreaInput"
1111
onChange={[Function]}
1212
placeholder=""
13+
readOnly={false}
1314
/>
1415
</div>
1516
`;

src/shared/components/GUIKit/Textarea/index.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ function Textarea({
1616
value,
1717
onChange,
1818
required,
19+
readonly,
1920
}) {
2021
const [val, setVal] = useState(value);
2122
const delayedOnChange = useRef(
@@ -25,6 +26,7 @@ function Textarea({
2526
return (
2627
<div className="textareaContainer" styleName="container">
2728
<textarea
29+
readOnly={readonly}
2830
defaultValue={value}
2931
placeholder={`${placeholder}${placeholder && required ? ' *' : ''}`}
3032
id="textAreaInput"
@@ -54,6 +56,7 @@ Textarea.defaultProps = {
5456
value: '',
5557
onChange: () => {},
5658
required: false,
59+
readonly: false,
5760
};
5861

5962
Textarea.propTypes = {
@@ -63,6 +66,7 @@ Textarea.propTypes = {
6366
value: PT.string,
6467
onChange: PT.func,
6568
required: PT.bool,
69+
readonly: PT.bool,
6670
};
6771

6872
export default Textarea;

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const ReactHtmlParserOptions = {
3939

4040
export default function GigDetails(props) {
4141
const {
42-
job, application, profile, onSendClick, isReferrSucess, formData, formErrors, onFormInputChange, isReferrError, getReferralId, referralId,
42+
job, application, profile, onSendClick, isReferrSucess, formData, formErrors, onFormInputChange, isReferrError, getReferralId, referralId, onReferralDone,
4343
} = props;
4444
let shareUrl;
4545
let showModalInitially = false;
@@ -186,6 +186,10 @@ export default function GigDetails(props) {
186186
onFormInputChange={onFormInputChange}
187187
isReferrError={isReferrError}
188188
referralId={referralId}
189+
onReferralDone={() => {
190+
onReferralDone();
191+
setModalOpen(false);
192+
}}
189193
/>
190194
)
191195
}
@@ -203,6 +207,7 @@ GigDetails.defaultProps = {
203207
application: null,
204208
profile: {},
205209
referralId: null,
210+
isReferrError: null,
206211
};
207212

208213
GigDetails.propTypes = {
@@ -214,7 +219,8 @@ GigDetails.propTypes = {
214219
formErrors: PT.shape().isRequired,
215220
formData: PT.shape().isRequired,
216221
onFormInputChange: PT.func.isRequired,
217-
isReferrError: PT.shape().isRequired,
222+
isReferrError: PT.shape(),
218223
getReferralId: PT.func.isRequired,
219224
referralId: PT.string,
225+
onReferralDone: PT.func.isRequired,
220226
};

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ function ReferralModal({
3737
onFormInputChange,
3838
isReferrError,
3939
referralId,
40+
onReferralDone,
4041
}) {
42+
let retUrl = window.location.href;
43+
retUrl += retUrl.match('\\?') ? '&referr=true' : '?referr=true';
4144
return (
4245
<Modal
4346
onCancel={onCloseButton}
@@ -65,6 +68,7 @@ function ReferralModal({
6568
errorMsg={formErrors.body}
6669
value={formData.body}
6770
required
71+
readonly
6872
/>
6973
</div>
7074
<div className={modalStyle.ctaButtons}>
@@ -90,7 +94,7 @@ function ReferralModal({
9094
) : null
9195
}
9296
{
93-
!referralId && (
97+
!referralId && !isReferrError && (
9498
<div className={modalStyle.referrForm}>
9599
<p style={{ textAlign: 'center' }}>Loading your personal referral form...</p>
96100
<LoadingIndicator />
@@ -104,7 +108,7 @@ function ReferralModal({
104108
<p className={modalStyle.sucessMsg}>Your referral has been sent.</p>
105109
<div className={modalStyle.ctaButtons}>
106110
<PrimaryButton
107-
onClick={onCloseButton}
111+
onClick={onReferralDone}
108112
theme={{
109113
button: buttonThemes.tc['primary-green-md'],
110114
}}
@@ -145,17 +149,16 @@ function ReferralModal({
145149
<Link to={HELP_INFO_LINK} className={buttonThemes.tc['primary-white-md']} openNewTab="true">FIND OUT MORE</Link>
146150
<PrimaryButton
147151
onClick={() => {
148-
let retUrl = window.location.href;
149-
retUrl += retUrl.match('\\?') ? '&referr=true' : '?referr=true';
150-
window.location = `${config.URL.AUTH}/member/registration?retUrl=${encodeURIComponent(retUrl)}`;
152+
window.location = `${config.URL.AUTH}/member?retUrl=${encodeURIComponent(retUrl)}`;
151153
}}
152154
theme={{
153155
button: buttonThemes.tc['primary-green-md'],
154156
}}
155157
>
156-
REGISTER
158+
LOGIN
157159
</PrimaryButton>
158160
</div>
161+
<p className={modalStyle.regTxt}>Not a member? Register <a href={`${config.URL.AUTH}/member/registration?retUrl=${encodeURIComponent(retUrl)}`}>here</a>.</p>
159162
</div>
160163
)}
161164
</Modal>
@@ -165,6 +168,7 @@ function ReferralModal({
165168
ReferralModal.defaultProps = {
166169
profile: null,
167170
referralId: null,
171+
isReferrError: null,
168172
};
169173

170174
ReferralModal.propTypes = {
@@ -175,8 +179,9 @@ ReferralModal.propTypes = {
175179
formErrors: PT.shape().isRequired,
176180
formData: PT.shape().isRequired,
177181
onFormInputChange: PT.func.isRequired,
178-
isReferrError: PT.shape().isRequired,
182+
isReferrError: PT.shape(),
179183
referralId: PT.string,
184+
onReferralDone: PT.func.isRequired,
180185
};
181186

182187
export default ReferralModal;

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@
104104
@include xs-to-sm {
105105
padding: 50px 40px;
106106
}
107+
108+
.regTxt {
109+
font-size: 14px;
110+
margin: 10px 0 0;
111+
}
107112
}
108113
}
109114

src/shared/containers/Gigs/RecruitCRMJobDetails.jsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class RecruitCRMJobDetailsContainer extends React.Component {
2828
formData: {
2929
body: `Hey there!
3030
31-
Topcoder has a freelance gig that I thought you would be interested in. If you get the gig and complete it successfully we both get an extra $1,000.
31+
Topcoder has a freelance gig that I thought you would be interested in. If you get the gig and complete it successfully we both get an extra $500.
3232
3333
Check it out:
3434
https://www.topcoder.com/gigs/${props.id}`,
@@ -38,6 +38,7 @@ https://www.topcoder.com/gigs/${props.id}`,
3838
this.onSendClick = this.onSendClick.bind(this);
3939
this.onFormInputChange = this.onFormInputChange.bind(this);
4040
this.getReferralId = this.getReferralId.bind(this);
41+
this.onReferralDone = this.onReferralDone.bind(this);
4142
}
4243

4344
componentDidMount() {
@@ -100,7 +101,7 @@ https://www.topcoder.com/gigs/${props.id}`,
100101
const res = await fetch('/api/mailchimp/email', {
101102
method: 'POST',
102103
body: JSON.stringify({
103-
104+
from: `${profile.firstName} ${profile.lastName} via Topcoder Gigwork <[email protected]>`,
104105
to: formData.email,
105106
subject: `${profile.firstName} ${profile.lastName} Thinks This Topcoder Gig Is For You!`,
106107
text: formData.body,
@@ -114,12 +115,25 @@ https://www.topcoder.com/gigs/${props.id}`,
114115
isReferrError: await res.json(),
115116
});
116117
} else {
118+
await res.json();
117119
this.setState({
118120
isReferrSucess: true,
119121
});
120122
}
121123
}
122124

125+
/**
126+
* Reset the form when referral done
127+
*/
128+
onReferralDone() {
129+
const { formData } = this.state;
130+
delete formData.email;
131+
this.setState({
132+
isReferrSucess: false,
133+
formData,
134+
});
135+
}
136+
123137
/**
124138
* Get referral id for the logged user
125139
*/
@@ -191,6 +205,7 @@ https://www.topcoder.com/gigs/${props.id}`,
191205
isReferrError={isReferrError}
192206
getReferralId={this.getReferralId}
193207
referralId={referralId}
208+
onReferralDone={this.onReferralDone}
194209
/>
195210
);
196211
}

0 commit comments

Comments
 (0)