Skip to content

Commit

Permalink
Merge branch 'develop' into thrive-spooky1-4
Browse files Browse the repository at this point in the history
  • Loading branch information
luizrrodrigues authored Nov 30, 2021
2 parents 3c68b2b + 3a66e07 commit 45ea57f
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 58 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ workflows:
filters:
branches:
only:
- free
- ca-profile-bug-bash
# This is alternate dev env for parallel testing
- "build-qa":
context : org-global
Expand All @@ -363,7 +363,7 @@ workflows:
filters:
branches:
only:
- thrive-spooky1-4
- free
# This is stage env for production QA releases
- "build-prod-staging":
context : org-global
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default class ImageInput extends React.Component {
this.state = {
newBasicInfo: {},
isImageOversize: false,
isImageFile: true,
};
}

Expand Down Expand Up @@ -72,6 +73,13 @@ export default class ImageInput extends React.Component {
if (file === undefined) {
return;
}
const allowedTypes = ['image/png', 'image/jpg', 'image/jpeg'];
if (!allowedTypes.includes(file.type)) {
this.setState({
isImageFile: false,
});
return;
}
if (file.size > 2 * 1024 * 1024) {
// If file size is greater than 2 MB, show error message
this.setState({
Expand All @@ -81,6 +89,7 @@ export default class ImageInput extends React.Component {
}
this.setState({
isImageOversize: false,
isImageFile: true,
});
uploadPhotoInit();
loadImage.parseMetaData(file, (data) => {
Expand Down Expand Up @@ -126,7 +135,7 @@ export default class ImageInput extends React.Component {
deletingPhoto,
} = profileState;

const { newBasicInfo, isImageOversize } = this.state;
const { newBasicInfo, isImageOversize, isImageFile } = this.state;

return (
<div styleName="image">
Expand Down Expand Up @@ -157,7 +166,8 @@ export default class ImageInput extends React.Component {
<input type="file" name="image" accept="image/*" onChange={this.onUploadPhoto} id="change-image-input" className="hidden" />
</div>
</div>
{isImageOversize && <div styleName="error-message">Please select an image smaller than 2MB</div>}
{!isImageFile && <div styleName="error-message">Please select jpg, jpeg or png image files only</div>}
{isImageFile && isImageOversize && <div styleName="error-message">Please select an image smaller than 2MB</div>}
</div>
);
}
Expand Down
12 changes: 8 additions & 4 deletions src/shared/components/Settings/Profile/BasicInfo/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export default class BasicInfo extends ConsentComponent {
personalizationTrait: this.loadPersonalizationTrait(userTraits),
newBasicInfo: {
handle: '',
firstName: '',
lastName: '',
firstName: null,
lastName: null,
gender: '',
ethnicBackground: null,
shortBio: '',
Expand Down Expand Up @@ -377,6 +377,8 @@ export default class BasicInfo extends ConsentComponent {
}
if (_.has(value, 'firstName')) {
newBasicInfo.firstName = value.firstName;
} else {
newBasicInfo.firstName = '';
}
if (_.has(value, 'gender')) {
newBasicInfo.gender = value.gender;
Expand All @@ -390,6 +392,8 @@ export default class BasicInfo extends ConsentComponent {
}
if (_.has(value, 'lastName')) {
newBasicInfo.lastName = value.lastName;
} else {
newBasicInfo.lastName = '';
}
if (_.has(value, 'primaryInterestInTopcoder')) {
newBasicInfo.primaryInterestInTopcoder = value.primaryInterestInTopcoder;
Expand Down Expand Up @@ -501,7 +505,7 @@ export default class BasicInfo extends ConsentComponent {
<div styleName="field col-2">
<span styleName="text-required">* Required</span>
<input disabled={!canModifyTrait} id="firstName" name="firstName" type="text" placeholder="First Name" onChange={this.onUpdateInput} value={newBasicInfo.firstName} maxLength="64" required />
<ErrorMessage invalid={_.isEmpty(newBasicInfo.firstName) && inputChanged} message="First Name cannot be empty" />
<ErrorMessage invalid={_.isEmpty(newBasicInfo.firstName) && !_.isNull(newBasicInfo.firstName) && inputChanged} message="First Name cannot be empty" />
</div>
</div>
<div styleName="row">
Expand All @@ -514,7 +518,7 @@ export default class BasicInfo extends ConsentComponent {
<div styleName="field col-2">
<span styleName="text-required">* Required</span>
<input disabled={!canModifyTrait} id="lastName" name="lastName" type="text" placeholder="Last Name" onChange={this.onUpdateInput} value={newBasicInfo.lastName} maxLength="64" required />
<ErrorMessage invalid={_.isEmpty(newBasicInfo.lastName) && inputChanged} message="Last Name cannot be empty" />
<ErrorMessage invalid={_.isEmpty(newBasicInfo.lastName) && !_.isNull(newBasicInfo.lastName) && inputChanged} message="Last Name cannot be empty" />
</div>
</div>
<div styleName="row">
Expand Down
93 changes: 43 additions & 50 deletions src/shared/containers/Gigs/RecruitCRMJobDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,6 @@ ${config.URL.BASE}${config.GIGS_PAGES_PATH}/${props.id}`,
// exit no email sending
return;
}
// process sent log
let { emailInvitesLog, emailInvitesStatus } = growSurf.data.metadata;
if (!emailInvitesLog) emailInvitesLog = '';
// check if email is in sent log alredy?
const foundInLog = emailInvitesLog.indexOf(email);
if (foundInLog !== -1) {
this.setState({
isReferrError: {
message: `${email} was already invited.`,
userError: true,
},
});
// exit no email sending
return;
}
// check if email is already referred?
const growCheck = await fetch(`${PROXY_ENDPOINT}/growsurf/participant/${email}`);
if (growCheck.status === 200) {
Expand Down Expand Up @@ -125,43 +110,51 @@ ${config.URL.BASE}${config.GIGS_PAGES_PATH}/${props.id}`,
// exit no email tracking due to the error
return;
}
// parse the log to array of emails
if (emailInvitesLog.length) {
emailInvitesLog = emailInvitesLog.split(',');
} else emailInvitesLog = [];
// prepare growSurf update payload
// we keep only 10 emails in the log to justify program rules
if (emailInvitesLog.length < 10) {
emailInvitesLog.push(email);
}
// Auto change status when 10 emails sent
if (emailInvitesLog.length === 10 && emailInvitesStatus !== 'Paid' && emailInvitesStatus !== 'Payment Pending') {
emailInvitesStatus = 'Payment Pending';
}
// put the tracking update in growsurf
const updateRed = await fetch(`${PROXY_ENDPOINT}/growsurf/participant/${growSurf.data.id}`, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${tokenV3}`,
},
body: JSON.stringify({
...growSurf.data,
metadata: {
...growSurf.data.metadata,
emailInvitesSent: Number(growSurf.data.metadata.emailInvitesSent || 0) + 1,
emailInvitesLog: emailInvitesLog.join(),
emailInvitesStatus,
// process sent log
let { emailInvitesLog, emailInvitesStatus } = growSurf.data.metadata;
if (!emailInvitesLog) emailInvitesLog = '';
// check if email is in sent log alredy?
const foundInLog = emailInvitesLog.indexOf(email);
// only when email is new - put it in log, update counters and etc.
if (foundInLog === -1) {
// parse the log to array of emails
if (emailInvitesLog.length) {
emailInvitesLog = emailInvitesLog.split(',');
} else emailInvitesLog = [];
// prepare growSurf update payload
// we keep only 10 emails in the log to justify program rules
if (emailInvitesLog.length < 10) {
emailInvitesLog.push(email);
}
// Auto change status when 10 emails sent
if (emailInvitesLog.length === 10 && emailInvitesStatus !== 'Paid' && emailInvitesStatus !== 'Payment Pending') {
emailInvitesStatus = 'Payment Pending';
}
// put the tracking update in growsurf
const updateRed = await fetch(`${PROXY_ENDPOINT}/growsurf/participant/${growSurf.data.id}`, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${tokenV3}`,
},
}),
});
if (updateRed.status >= 300) {
this.setState({
isReferrError: await updateRed.json(),
body: JSON.stringify({
...growSurf.data,
metadata: {
...growSurf.data.metadata,
emailInvitesSent: Number(growSurf.data.metadata.emailInvitesSent || 0) + 1,
emailInvitesLog: emailInvitesLog.join(),
emailInvitesStatus,
},
}),
});
// exit no email tracking due to the error
// just notify the user about it
return;
if (updateRed.status >= 300) {
this.setState({
isReferrError: await updateRed.json(),
});
// exit no email tracking due to the error
// just notify the user about it
return;
}
}
// finally do:
this.setState({
Expand Down

0 comments on commit 45ea57f

Please sign in to comment.