Skip to content

Commit d93442c

Browse files
Merge pull request #5969 from topcoder-platform/jan-updates-1
Jan updates 1
2 parents 11561bc + d42e7d2 commit d93442c

File tree

7 files changed

+102
-60
lines changed

7 files changed

+102
-60
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ workflows:
363363
filters:
364364
branches:
365365
only:
366-
- mm-leaderboard-theme
366+
- jan-updates-1
367367
# This is stage env for production QA releases
368368
- "build-prod-staging":
369369
context : org-global

__tests__/shared/components/__snapshots__/TopcoderFooter.jsx.snap

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,6 @@ exports[`Matches shallow shapshot 1`] = `
163163
Blog
164164
</a>
165165
</li>
166-
<li
167-
className="src-shared-components-TopcoderFooter-___style__link___3-nzm"
168-
>
169-
<a
170-
href="https://www.topcoder-dev.com/community/pipeline"
171-
>
172-
Challenge Pipeline
173-
</a>
174-
</li>
175166
<li
176167
className="src-shared-components-TopcoderFooter-___style__link___3-nzm"
177168
>

src/shared/components/Looker/index.jsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import PT from 'prop-types';
2121
import _ from 'lodash';
2222
import React, { Component } from 'react';
2323
import { fixStyle } from 'utils/contentful';
24+
import { getRatingColor } from 'utils/tc';
2425
import cn from 'classnames';
2526
import { Scrollbars } from 'react-custom-scrollbars';
2627
import './style.scss';
@@ -46,6 +47,7 @@ export default class Looker extends Component {
4647
tableHeight,
4748
tableWidth,
4849
headerIndexCol,
50+
ratingProp,
4951
} = this.props;
5052

5153
let {
@@ -166,7 +168,11 @@ export default class Looker extends Component {
166168
}
167169
return value ? (
168170
<td key={record[prop]} style={fixStyle(styles)} title={value} styleName="body-row">
169-
{memberLinks ? (<a styleName="handle-link" href={`${window.origin}/members/${value}`} target={`${_.includes(window.origin, 'www') ? '_self' : '_blank'}`}>{value}</a>) : value}
171+
{memberLinks ? (
172+
<a styleName="handle-link" href={`${window.origin}/members/${value}`} target={`${_.includes(window.origin, 'www') ? '_self' : '_blank'}`} style={{ color: ratingProp ? getRatingColor(record[ratingProp]) : null }}>
173+
{value}
174+
</a>
175+
) : value}
170176
</td>
171177
) : null;
172178
})
@@ -232,6 +238,7 @@ Looker.defaultProps = {
232238
tableHeight: '100%',
233239
tableWidth: '100%',
234240
headerIndexCol: '',
241+
ratingProp: null,
235242
};
236243

237244
Looker.propTypes = {
@@ -253,4 +260,5 @@ Looker.propTypes = {
253260
PT.func,
254261
]),
255262
headerIndexCol: PT.string,
263+
ratingProp: PT.string,
256264
};

src/shared/components/Looker/style.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ $light-gray: #d4d4d4;
106106
@include roboto-medium;
107107

108108
font-weight: 500;
109-
color: #0d61bf !important;
109+
color: #0d61bf;
110110
text-decoration: underline;
111111

112112
&:hover {

src/shared/components/Settings/Preferences/Email/index.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ function toastrError(title, message) {
2626
const SAVE_DELAY = 1000;
2727

2828
const newsletters = [
29-
{
30-
id: '9f950b43a1',
31-
name: 'Challenge Pipeline',
32-
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.',
33-
},
3429
{
3530
id: 'd0c48e9da3',
3631
name: 'Gig Work',
@@ -61,6 +56,11 @@ const newsletters = [
6156
name: 'Rapid Development Match (RDM) Reminders',
6257
desc: 'Receive notifications of our brand new RDMs! These rated, development matches will be a fun new way to engage with us!',
6358
},
59+
{
60+
id: 'ee26600945',
61+
name: 'NASA Community',
62+
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>.',
63+
},
6464
];
6565
const programs = [
6666
{

src/shared/components/TopcoderFooter/index.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ export default function TopcoderFooter() {
6969
<div styleName="sep-line" />
7070
<ul styleName="navi-col-links">
7171
<Link to={`${base}/blog`}>Blog</Link>
72-
<Link to={`${base}/community/pipeline`}>Challenge Pipeline</Link>
7372
<Link to={`${base}/community/events`}>Events Calendar</Link>
7473
<Link to={`${config.URL.FORUMS_VANILLA}`}>Forums</Link>
7574
<Link to={`${base}/community/member-programs`}>Programs</Link>

src/shared/containers/NewsletterSignupForMembers.jsx

Lines changed: 86 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,16 @@ class NewsletterSignupForMembersContainer extends React.Component {
3131

3232
// Get interestIds and interest request object for mailchimp api
3333
// to use in checkSubscription and subscribe function
34-
const { groups } = props;
34+
const { groups, tags } = props;
3535
this.groupsIds = null;
36+
this.tagNames = null;
3637
if (groups !== '') {
3738
this.groupsIds = groups.split(/ *, */);
3839
this.groupsIds[this.groupsIds.length - 1] = this.groupsIds[this.groupsIds.length - 1].replace(/^\s+|\s+$/g, '');
3940
}
41+
if (tags) {
42+
this.tagNames = tags.split(',');
43+
}
4044
this.isSubscribed = false;
4145

4246
this.state = {
@@ -89,13 +93,25 @@ class NewsletterSignupForMembersContainer extends React.Component {
8993
.then((dataResponse) => {
9094
if (dataResponse.status === 'subscribed') {
9195
this.isSubscribed = true;
92-
const subscribedTags = _.keys(_.pickBy(dataResponse.interests, v => v));
93-
if (subscribedTags.length) {
94-
if (_.intersection(subscribedTags, this.groupsIds).length) {
95-
this.setState({ signupState: SIGNUP_NEWSLETTER.HIDDEN });
96+
if (this.groupsIds) {
97+
const subscribedGroups = _.keys(_.pickBy(dataResponse.interests, v => v));
98+
if (subscribedGroups.length) {
99+
if (_.intersection(subscribedGroups, this.groupsIds).length) {
100+
this.setState({ signupState: SIGNUP_NEWSLETTER.HIDDEN });
101+
}
102+
} else {
103+
this.setState({ signupState: SIGNUP_NEWSLETTER.DEFAULT });
104+
}
105+
}
106+
if (!this.groupsIds && this.tagNames) {
107+
const subscribedTags = _.map(dataResponse.tags, t => t.name);
108+
if (subscribedTags.length) {
109+
if (_.intersection(subscribedTags, this.tagNames).length) {
110+
this.setState({ signupState: SIGNUP_NEWSLETTER.HIDDEN });
111+
}
112+
} else {
113+
this.setState({ signupState: SIGNUP_NEWSLETTER.DEFAULT });
96114
}
97-
} else {
98-
this.setState({ signupState: SIGNUP_NEWSLETTER.DEFAULT });
99115
}
100116
} else {
101117
this.setState({ signupState: SIGNUP_NEWSLETTER.DEFAULT });
@@ -107,49 +123,75 @@ class NewsletterSignupForMembersContainer extends React.Component {
107123
const {
108124
listId, user,
109125
} = this.props;
110-
111-
const fetchUrl = `${PROXY_ENDPOINT}/${listId}/members/${this.emailHash}`;
112-
113-
let data = {};
114-
if (!this.isSubscribed) {
115-
data = {
116-
email_address: user.email,
117-
status: 'subscribed',
118-
merge_fields: {
119-
FNAME: user.FNAME,
120-
LNAME: user.LNAME,
121-
},
122-
};
123-
}
126+
const isTagsUpdate = !!this.tagNames;
127+
const fetchUrl = `${PROXY_ENDPOINT}/${listId}/members/${this.emailHash}${isTagsUpdate ? '/tags' : ''}`;
124128

125129
if (this.groupsIds) {
130+
let data = {};
131+
if (!this.isSubscribed) {
132+
data = {
133+
email_address: user.email,
134+
status: 'subscribed',
135+
merge_fields: {
136+
FNAME: user.FNAME,
137+
LNAME: user.LNAME,
138+
},
139+
};
140+
}
126141
data.interests = {};
127142
// eslint-disable-next-line array-callback-return
128143
this.groupsIds.map((group) => {
129144
data.interests[group] = true;
130145
});
131-
}
132146

133-
const formData = JSON.stringify(data);
134-
// use proxy for avoid 'Access-Control-Allow-Origin' bug
135-
await fetch(fetchUrl, {
136-
method: 'PUT',
137-
headers: {
138-
'Content-Type': 'application/json',
139-
},
140-
body: formData,
141-
}).then(result => result.json()).then((dataResponse) => {
142-
if (dataResponse.status === 'subscribed') {
143-
// regist success
144-
this.setState({ signupState: SIGNUP_NEWSLETTER.SIGNEDUP });
145-
} else {
146-
// regist fail
147-
this.setState({
148-
signupState: SIGNUP_NEWSLETTER.ERROR,
149-
message: dataResponse.detail,
150-
});
151-
}
152-
});
147+
const formData = JSON.stringify(data);
148+
// use proxy for avoid 'Access-Control-Allow-Origin' bug
149+
await fetch(fetchUrl, {
150+
method: 'PUT',
151+
headers: {
152+
'Content-Type': 'application/json',
153+
},
154+
body: formData,
155+
}).then(result => result.json()).then((dataResponse) => {
156+
if (dataResponse.status === 'subscribed') {
157+
// regist success
158+
this.setState({ signupState: SIGNUP_NEWSLETTER.SIGNEDUP });
159+
} else {
160+
// regist fail
161+
this.setState({
162+
signupState: SIGNUP_NEWSLETTER.ERROR,
163+
message: dataResponse.detail,
164+
});
165+
}
166+
});
167+
}
168+
if (!this.groupsIds && this.tagNames) {
169+
const formData = JSON.stringify({
170+
tags: this.tagNames.map(tName => ({
171+
name: tName,
172+
status: 'active',
173+
})),
174+
});
175+
// use proxy for avoid 'Access-Control-Allow-Origin' bug
176+
await fetch(fetchUrl, {
177+
method: 'POST',
178+
headers: {
179+
'Content-Type': 'application/json',
180+
},
181+
body: formData,
182+
}).then(result => result.json()).then((dataResponse) => {
183+
if (dataResponse.status === 204) {
184+
// regist success
185+
this.setState({ signupState: SIGNUP_NEWSLETTER.SIGNEDUP });
186+
} else {
187+
// regist fail
188+
this.setState({
189+
signupState: SIGNUP_NEWSLETTER.ERROR,
190+
message: dataResponse.detail,
191+
});
192+
}
193+
});
194+
}
153195
}
154196

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

199242
NewsletterSignupForMembersContainer.propTypes = {
@@ -206,6 +249,7 @@ NewsletterSignupForMembersContainer.propTypes = {
206249
buttonTheme: PT.string,
207250
title: PT.string,
208251
desc: PT.string,
252+
tags: PT.string,
209253
};
210254

211255
function mapStateToProps(state, ownProps) {

0 commit comments

Comments
 (0)