Skip to content

Feature contentful #4388

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 2 commits into from
May 21, 2020
Merged
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
32 changes: 1 addition & 31 deletions src/shared/components/Settings/Preferences/Email/index.jsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
/**
* Email Preferences component.
*/
import { debounce, isEqual, map } from 'lodash';
import { debounce, isEqual } from 'lodash';
import React from 'react';
import PT from 'prop-types';

import ConsentComponent from 'components/Settings/ConsentComponent';
import ToggleableItem from 'components/Settings/ToggleableItem';

import './styles.scss';

const SAVE_DELAY = 1000;
const newsletters = [
{
id: 'TOPCODER_NL_GEN',
name: 'General Newsletter',
desc: 'News summary from Topcoder',
},
];

export default class EmailPreferences extends ConsentComponent {
saveEmailPreferences = debounce(() => {
Expand Down Expand Up @@ -85,33 +77,11 @@ export default class EmailPreferences extends ConsentComponent {
}

render() {
const { profileState: { emailPreferences } } = this.props;
return (
<div styleName="EmailPreferences">
<h1 styleName="title">
E-Mail Preferences
</h1>
<div styleName="preferences-container">
{
this.shouldRenderConsent() && this.renderConsent()
}
{
map(newsletters, (newsletter) => {
const checked = emailPreferences ? emailPreferences[newsletter.id] : false;
return (
<ToggleableItem
key={newsletter.id}
id={newsletter.id}
value={newsletter.id}
checked={checked}
primaryText={newsletter.name}
secondaryText={newsletter.desc}
onToggle={e => this.onHandleChange(newsletter.id, e.target.checked)}
/>
);
})
}
</div>
</div>
);
}
Expand Down