File tree Expand file tree Collapse file tree 1 file changed +31
-1
lines changed
src/shared/components/Settings/Preferences/Email Expand file tree Collapse file tree 1 file changed +31
-1
lines changed Original file line number Diff line number Diff line change 1
1
/**
2
2
* Email Preferences component.
3
3
*/
4
- import { debounce , isEqual } from 'lodash' ;
4
+ import { debounce , isEqual , map } from 'lodash' ;
5
5
import React from 'react' ;
6
6
import PT from 'prop-types' ;
7
7
8
8
import ConsentComponent from 'components/Settings/ConsentComponent' ;
9
+ import ToggleableItem from 'components/Settings/ToggleableItem' ;
9
10
10
11
import './styles.scss' ;
11
12
12
13
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
+ ] ;
13
21
14
22
export default class EmailPreferences extends ConsentComponent {
15
23
saveEmailPreferences = debounce ( ( ) => {
@@ -77,11 +85,33 @@ export default class EmailPreferences extends ConsentComponent {
77
85
}
78
86
79
87
render ( ) {
88
+ const { profileState : { emailPreferences } } = this . props ;
80
89
return (
81
90
< div styleName = "EmailPreferences" >
82
91
< h1 styleName = "title" >
83
92
E-Mail Preferences
84
93
</ 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 >
85
115
</ div >
86
116
) ;
87
117
}
You can’t perform that action at this time.
0 commit comments