Skip to content

Jan updates 1 #5969

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ workflows:
filters:
branches:
only:
- mm-leaderboard-theme
- jan-updates-1
# 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 @@ -163,15 +163,6 @@ exports[`Matches shallow shapshot 1`] = `
Blog
</a>
</li>
<li
className="src-shared-components-TopcoderFooter-___style__link___3-nzm"
>
<a
href="https://www.topcoder-dev.com/community/pipeline"
>
Challenge Pipeline
</a>
</li>
<li
className="src-shared-components-TopcoderFooter-___style__link___3-nzm"
>
Expand Down
10 changes: 9 additions & 1 deletion src/shared/components/Looker/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import PT from 'prop-types';
import _ from 'lodash';
import React, { Component } from 'react';
import { fixStyle } from 'utils/contentful';
import { getRatingColor } from 'utils/tc';
import cn from 'classnames';
import { Scrollbars } from 'react-custom-scrollbars';
import './style.scss';
Expand All @@ -46,6 +47,7 @@ export default class Looker extends Component {
tableHeight,
tableWidth,
headerIndexCol,
ratingProp,
} = this.props;

let {
Expand Down Expand Up @@ -166,7 +168,11 @@ export default class Looker extends Component {
}
return value ? (
<td key={record[prop]} style={fixStyle(styles)} title={value} styleName="body-row">
{memberLinks ? (<a styleName="handle-link" href={`${window.origin}/members/${value}`} target={`${_.includes(window.origin, 'www') ? '_self' : '_blank'}`}>{value}</a>) : value}
{memberLinks ? (
<a styleName="handle-link" href={`${window.origin}/members/${value}`} target={`${_.includes(window.origin, 'www') ? '_self' : '_blank'}`} style={{ color: ratingProp ? getRatingColor(record[ratingProp]) : null }}>
{value}
</a>
) : value}
</td>
) : null;
})
Expand Down Expand Up @@ -232,6 +238,7 @@ Looker.defaultProps = {
tableHeight: '100%',
tableWidth: '100%',
headerIndexCol: '',
ratingProp: null,
};

Looker.propTypes = {
Expand All @@ -253,4 +260,5 @@ Looker.propTypes = {
PT.func,
]),
headerIndexCol: PT.string,
ratingProp: PT.string,
};
2 changes: 1 addition & 1 deletion src/shared/components/Looker/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ $light-gray: #d4d4d4;
@include roboto-medium;

font-weight: 500;
color: #0d61bf !important;
color: #0d61bf;
text-decoration: underline;

&:hover {
Expand Down
10 changes: 5 additions & 5 deletions src/shared/components/Settings/Preferences/Email/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ function toastrError(title, message) {
const SAVE_DELAY = 1000;

const newsletters = [
{
id: '9f950b43a1',
name: 'Challenge Pipeline',
desc: 'Subscribe to this newsletter if you want to get updates on the types of challenges coming up in the future. To view these challenges at your leisure you can always visit the <a href="https://www.topcoder.com/community/pipeline" style="color:#0d61bf;text-decoration:underline">Challenge Pipeline</a> page.',
},
{
id: 'd0c48e9da3',
name: 'Gig Work',
Expand Down Expand Up @@ -61,6 +56,11 @@ const newsletters = [
name: 'Rapid Development Match (RDM) Reminders',
desc: 'Receive notifications of our brand new RDMs! These rated, development matches will be a fun new way to engage with us!',
},
{
id: 'ee26600945',
name: 'NASA Community',
desc: 'Receive email notifications for all the latest news and announcements of our <a href="https://www.topcoder.com/community/nasa" style="color:#0d61bf;text-decoration:underline">NASA Member Program</a>.',
},
];
const programs = [
{
Expand Down
1 change: 0 additions & 1 deletion src/shared/components/TopcoderFooter/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ export default function TopcoderFooter() {
<div styleName="sep-line" />
<ul styleName="navi-col-links">
<Link to={`${base}/blog`}>Blog</Link>
<Link to={`${base}/community/pipeline`}>Challenge Pipeline</Link>
<Link to={`${base}/community/events`}>Events Calendar</Link>
<Link to={`${config.URL.FORUMS_VANILLA}`}>Forums</Link>
<Link to={`${base}/community/member-programs`}>Programs</Link>
Expand Down
128 changes: 86 additions & 42 deletions src/shared/containers/NewsletterSignupForMembers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,16 @@ class NewsletterSignupForMembersContainer extends React.Component {

// Get interestIds and interest request object for mailchimp api
// to use in checkSubscription and subscribe function
const { groups } = props;
const { groups, tags } = props;
this.groupsIds = null;
this.tagNames = null;
if (groups !== '') {
this.groupsIds = groups.split(/ *, */);
this.groupsIds[this.groupsIds.length - 1] = this.groupsIds[this.groupsIds.length - 1].replace(/^\s+|\s+$/g, '');
}
if (tags) {
this.tagNames = tags.split(',');
}
this.isSubscribed = false;

this.state = {
Expand Down Expand Up @@ -89,13 +93,25 @@ class NewsletterSignupForMembersContainer extends React.Component {
.then((dataResponse) => {
if (dataResponse.status === 'subscribed') {
this.isSubscribed = true;
const subscribedTags = _.keys(_.pickBy(dataResponse.interests, v => v));
if (subscribedTags.length) {
if (_.intersection(subscribedTags, this.groupsIds).length) {
this.setState({ signupState: SIGNUP_NEWSLETTER.HIDDEN });
if (this.groupsIds) {
const subscribedGroups = _.keys(_.pickBy(dataResponse.interests, v => v));
if (subscribedGroups.length) {
if (_.intersection(subscribedGroups, this.groupsIds).length) {
this.setState({ signupState: SIGNUP_NEWSLETTER.HIDDEN });
}
} else {
this.setState({ signupState: SIGNUP_NEWSLETTER.DEFAULT });
}
}
if (!this.groupsIds && this.tagNames) {
const subscribedTags = _.map(dataResponse.tags, t => t.name);
if (subscribedTags.length) {
if (_.intersection(subscribedTags, this.tagNames).length) {
this.setState({ signupState: SIGNUP_NEWSLETTER.HIDDEN });
}
} else {
this.setState({ signupState: SIGNUP_NEWSLETTER.DEFAULT });
}
} else {
this.setState({ signupState: SIGNUP_NEWSLETTER.DEFAULT });
}
} else {
this.setState({ signupState: SIGNUP_NEWSLETTER.DEFAULT });
Expand All @@ -107,49 +123,75 @@ class NewsletterSignupForMembersContainer extends React.Component {
const {
listId, user,
} = this.props;

const fetchUrl = `${PROXY_ENDPOINT}/${listId}/members/${this.emailHash}`;

let data = {};
if (!this.isSubscribed) {
data = {
email_address: user.email,
status: 'subscribed',
merge_fields: {
FNAME: user.FNAME,
LNAME: user.LNAME,
},
};
}
const isTagsUpdate = !!this.tagNames;
const fetchUrl = `${PROXY_ENDPOINT}/${listId}/members/${this.emailHash}${isTagsUpdate ? '/tags' : ''}`;

if (this.groupsIds) {
let data = {};
if (!this.isSubscribed) {
data = {
email_address: user.email,
status: 'subscribed',
merge_fields: {
FNAME: user.FNAME,
LNAME: user.LNAME,
},
};
}
data.interests = {};
// eslint-disable-next-line array-callback-return
this.groupsIds.map((group) => {
data.interests[group] = true;
});
}

const formData = JSON.stringify(data);
// use proxy for avoid 'Access-Control-Allow-Origin' bug
await fetch(fetchUrl, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
body: formData,
}).then(result => result.json()).then((dataResponse) => {
if (dataResponse.status === 'subscribed') {
// regist success
this.setState({ signupState: SIGNUP_NEWSLETTER.SIGNEDUP });
} else {
// regist fail
this.setState({
signupState: SIGNUP_NEWSLETTER.ERROR,
message: dataResponse.detail,
});
}
});
const formData = JSON.stringify(data);
// use proxy for avoid 'Access-Control-Allow-Origin' bug
await fetch(fetchUrl, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
body: formData,
}).then(result => result.json()).then((dataResponse) => {
if (dataResponse.status === 'subscribed') {
// regist success
this.setState({ signupState: SIGNUP_NEWSLETTER.SIGNEDUP });
} else {
// regist fail
this.setState({
signupState: SIGNUP_NEWSLETTER.ERROR,
message: dataResponse.detail,
});
}
});
}
if (!this.groupsIds && this.tagNames) {
const formData = JSON.stringify({
tags: this.tagNames.map(tName => ({
name: tName,
status: 'active',
})),
});
// use proxy for avoid 'Access-Control-Allow-Origin' bug
await fetch(fetchUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: formData,
}).then(result => result.json()).then((dataResponse) => {
if (dataResponse.status === 204) {
// regist success
this.setState({ signupState: SIGNUP_NEWSLETTER.SIGNEDUP });
} else {
// regist fail
this.setState({
signupState: SIGNUP_NEWSLETTER.ERROR,
message: dataResponse.detail,
});
}
});
}
}

showSignupConfirmModal() {
Expand Down Expand Up @@ -194,6 +236,7 @@ NewsletterSignupForMembersContainer.defaultProps = {
buttonTheme: 'primary-green-md',
title: 'Sign up for the Topcoder Newsletter',
desc: 'Do you want to subscribe to this newsletter?',
tags: null,
};

NewsletterSignupForMembersContainer.propTypes = {
Expand All @@ -206,6 +249,7 @@ NewsletterSignupForMembersContainer.propTypes = {
buttonTheme: PT.string,
title: PT.string,
desc: PT.string,
tags: PT.string,
};

function mapStateToProps(state, ownProps) {
Expand Down