Skip to content

Commit 2e2a0ed

Browse files
committed
Implement #4165
1 parent a8f25bf commit 2e2a0ed

File tree

1 file changed

+31
-1
lines changed
  • src/shared/components/Settings/Preferences/Email

1 file changed

+31
-1
lines changed

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

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
/**
22
* Email Preferences component.
33
*/
4-
import { debounce, isEqual } from 'lodash';
4+
import { debounce, isEqual, map } from 'lodash';
55
import React from 'react';
66
import PT from 'prop-types';
77

88
import ConsentComponent from 'components/Settings/ConsentComponent';
9+
import ToggleableItem from 'components/Settings/ToggleableItem';
910

1011
import './styles.scss';
1112

1213
const SAVE_DELAY = 1000;
14+
const newsletters = [
15+
{
16+
id: 'TOPCODER_NL_GEN',
17+
name: 'General Newsletter',
18+
desc: 'News summary from Topcoder',
19+
},
20+
];
1321

1422
export default class EmailPreferences extends ConsentComponent {
1523
saveEmailPreferences = debounce(() => {
@@ -77,11 +85,33 @@ export default class EmailPreferences extends ConsentComponent {
7785
}
7886

7987
render() {
88+
const { profileState: { emailPreferences } } = this.props;
8089
return (
8190
<div styleName="EmailPreferences">
8291
<h1 styleName="title">
8392
E-Mail Preferences
8493
</h1>
94+
<div styleName="preferences-container">
95+
{
96+
this.shouldRenderConsent() && this.renderConsent()
97+
}
98+
{
99+
map(newsletters, (newsletter) => {
100+
const checked = emailPreferences ? emailPreferences[newsletter.id] : false;
101+
return (
102+
<ToggleableItem
103+
key={newsletter.id}
104+
id={newsletter.id}
105+
value={newsletter.id}
106+
checked={checked}
107+
primaryText={newsletter.name}
108+
secondaryText={newsletter.desc}
109+
onToggle={e => this.onHandleChange(newsletter.id, e.target.checked)}
110+
/>
111+
);
112+
})
113+
}
114+
</div>
85115
</div>
86116
);
87117
}

0 commit comments

Comments
 (0)