Skip to content

Commit 141525b

Browse files
committed
Final fixes email revamp
1 parent ef40455 commit 141525b

File tree

4 files changed

+29
-20
lines changed

4 files changed

+29
-20
lines changed

__tests__/shared/components/Settings/Preferences/Email/__snapshots__/index.jsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ exports[`renders email preferences setting page correctly 1`] = `
1313
className="src-shared-components-Settings-Preferences-Email-___styles__unsubscribed-msg___3yh6s"
1414
>
1515
<h3>
16-
You have unsubscribed from Topcoder Emails
16+
You are not subscribed to receive Topcoder emails
1717
</h3>
1818
<p>
19-
If this was a mistake or if you would like to resubscribe, please click the button below and fill out the form.
19+
If this was a mistake or if you would like to resubscribe, please click the button below.
2020
</p>
2121
<ThemedButton
2222
active={false}

src/shared/components/NewsletterSignupForMembers/ConfirmModal/style.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,9 @@
3333

3434
button {
3535
margin: 24px 12px 0;
36+
37+
&:first-child {
38+
margin-right: 12px !important;
39+
}
3640
}
3741
}

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable max-len */
12
/**
23
* Email Preferences component.
34
*/
@@ -66,7 +67,7 @@ const programs = [
6667
{
6768
id: 'cafe98d7a7',
6869
name: 'Beta Testers',
69-
desc: '',
70+
desc: 'If you have applied and been approved as a <a href="https://www.topcoder.com/community/member-programs/beta-testers" style="color:#0d61bf;text-decoration:underline">Beta Tester</a>, you may control the emails you receive here.',
7071
},
7172
];
7273

@@ -120,10 +121,8 @@ export default class EmailPreferences extends React.Component {
120121
{
121122
status !== 'subscribed' ? (
122123
<div styleName="unsubscribed-msg">
123-
<h3>You have unsubscribed from Topcoder Emails</h3>
124-
<p>If this was a mistake or if you would like to resubscribe,
125-
please click the button below.
126-
</p>
124+
<h3>You are not subscribed to receive Topcoder emails</h3>
125+
<p>If this was a mistake or if you would like to resubscribe, please click the button below.</p>
127126
<PrimaryButton
128127
onClick={() => resubscibeEmails(email)}
129128
>

src/shared/containers/NewsletterSignupForMembers.jsx

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ 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 { tags } = props;
35-
this.tagsIds = null;
36-
if (tags !== '') {
37-
this.tagsIds = tags.split(/ *, */);
38-
this.tagsIds[this.tagsIds.length - 1] = this.tagsIds[this.tagsIds.length - 1].replace(/^\s+|\s+$/g, '');
34+
const { groups } = props;
35+
this.groupsIds = null;
36+
if (groups !== '') {
37+
this.groupsIds = groups.split(/ *, */);
38+
this.groupsIds[this.groupsIds.length - 1] = this.groupsIds[this.groupsIds.length - 1].replace(/^\s+|\s+$/g, '');
3939
}
4040
this.isSubscribed = false;
4141

@@ -89,9 +89,9 @@ class NewsletterSignupForMembersContainer extends React.Component {
8989
.then((dataResponse) => {
9090
if (dataResponse.status === 'subscribed') {
9191
this.isSubscribed = true;
92-
const subscribedTags = dataResponse.tags.map(t => t.name);
92+
const subscribedTags = _.keys(_.pickBy(dataResponse.interests, v => v));
9393
if (subscribedTags.length) {
94-
if (_.intersection(subscribedTags, this.tagsIds).length) {
94+
if (_.intersection(subscribedTags, this.groupsIds).length) {
9595
this.setState({ signupState: SIGNUP_NEWSLETTER.HIDDEN });
9696
}
9797
} else {
@@ -108,7 +108,7 @@ class NewsletterSignupForMembersContainer extends React.Component {
108108
listId, user,
109109
} = this.props;
110110

111-
const fetchUrl = `${PROXY_ENDPOINT}/${listId}/members/${this.emailHash}/tags`;
111+
const fetchUrl = `${PROXY_ENDPOINT}/${listId}/members/${this.emailHash}`;
112112

113113
let data = {};
114114
if (!this.isSubscribed) {
@@ -122,18 +122,24 @@ class NewsletterSignupForMembersContainer extends React.Component {
122122
};
123123
}
124124

125-
if (this.tagsIds) data.tags = this.tagsIds.map(t => ({ name: t, status: 'active' }));
125+
if (this.groupsIds) {
126+
data.interests = {};
127+
// eslint-disable-next-line array-callback-return
128+
this.groupsIds.map((group) => {
129+
data.interests[group] = true;
130+
});
131+
}
126132

127133
const formData = JSON.stringify(data);
128134
// use proxy for avoid 'Access-Control-Allow-Origin' bug
129135
await fetch(fetchUrl, {
130-
method: 'POST',
136+
method: 'PUT',
131137
headers: {
132138
'Content-Type': 'application/json',
133139
},
134140
body: formData,
135141
}).then(result => result.json()).then((dataResponse) => {
136-
if (dataResponse.status === 204) {
142+
if (dataResponse.status === 'subscribed') {
137143
// regist success
138144
this.setState({ signupState: SIGNUP_NEWSLETTER.SIGNEDUP });
139145
} else {
@@ -183,7 +189,7 @@ class NewsletterSignupForMembersContainer extends React.Component {
183189
NewsletterSignupForMembersContainer.defaultProps = {
184190
token: '',
185191
label: 'Subscribe for Newsletter',
186-
tags: '',
192+
groups: '',
187193
user: null,
188194
buttonTheme: 'primary-green-md',
189195
title: 'Sign up for the Topcoder Newsletter',
@@ -194,7 +200,7 @@ NewsletterSignupForMembersContainer.propTypes = {
194200
authenticating: PT.bool.isRequired,
195201
token: PT.string,
196202
label: PT.string,
197-
tags: PT.string,
203+
groups: PT.string,
198204
listId: PT.string.isRequired,
199205
user: PT.shape(),
200206
buttonTheme: PT.string,

0 commit comments

Comments
 (0)