diff --git a/__tests__/shared/components/Settings/Preferences/Email/__snapshots__/index.jsx.snap b/__tests__/shared/components/Settings/Preferences/Email/__snapshots__/index.jsx.snap index f42130c0f8..585e1c49bf 100644 --- a/__tests__/shared/components/Settings/Preferences/Email/__snapshots__/index.jsx.snap +++ b/__tests__/shared/components/Settings/Preferences/Email/__snapshots__/index.jsx.snap @@ -7,11 +7,14 @@ exports[`renders email preferences setting page correctly 1`] = ` `; diff --git a/src/shared/components/Settings/Preferences/Email/data.jsx b/src/shared/components/Settings/Preferences/Email/data.jsx index 2319c6e40d..25ba7886b5 100644 --- a/src/shared/components/Settings/Preferences/Email/data.jsx +++ b/src/shared/components/Settings/Preferences/Email/data.jsx @@ -1,11 +1,20 @@ -import email from 'assets/images/preferences/email.svg'; -const data = { - id: 'email', - icon: email, +export const subscribe = { + id: 'subscribe', + icon: 'email', name: 'You are not subscribed to receive topcoder emails', description: 'If this was a mistake or if you would like to resubscribe, please click the “Subscribe” button.', linkTitle: 'SUBSCRIBE', + formLink: 'https://topcoder.us13.list-manage.com/subscribe/post?u=65bd5a1857b73643aad556093&id=28bfd3c062', + value: 'subscribe', }; -export default data; +export const unsubscribe = { + id: 'unsubscribe', + icon: 'email', + name: 'You are currently subscribed to receive topcoder emails', + description: 'If this was a mistake or if you would like to unsubscribe, please click the “Unsubscribe” button.', + linkTitle: 'UNSUBSCRIBE', + formLink: 'https://topcoder.us13.list-manage.com/unsubscribe?u=65bd5a1857b73643aad556093&id=28bfd3c062', + value: 'unsubscribe', +}; diff --git a/src/shared/components/Settings/Preferences/Email/index.jsx b/src/shared/components/Settings/Preferences/Email/index.jsx index f8268700ef..152ffa6b55 100644 --- a/src/shared/components/Settings/Preferences/Email/index.jsx +++ b/src/shared/components/Settings/Preferences/Email/index.jsx @@ -8,7 +8,7 @@ import PT from 'prop-types'; import { toastr } from 'react-redux-toastr'; import ToggleableItem from 'components/Settings/ToggleableItem'; import Item from '../List/Item'; -import subscribe from './data'; +import { subscribe, unsubscribe } from './data'; import './styles.scss'; @@ -128,16 +128,31 @@ export default class EmailPreferences extends React.Component { { status !== 'subscribed' ? ( ) : ( + { map(newsletters, (newsletter) => { const checked = emailPreferences[newsletter.id]; diff --git a/src/shared/components/Settings/Preferences/List/Item/index.jsx b/src/shared/components/Settings/Preferences/List/Item/index.jsx index a4d2cf8bbf..0cb8f2c79d 100644 --- a/src/shared/components/Settings/Preferences/List/Item/index.jsx +++ b/src/shared/components/Settings/Preferences/List/Item/index.jsx @@ -4,6 +4,7 @@ import React from 'react'; import PT from 'prop-types'; import ReactSVG from 'react-svg'; +import cn from 'classnames'; import { isomorphy } from 'topcoder-react-utils'; import './styles.scss'; @@ -14,19 +15,22 @@ if (isomorphy.isClientSide()) { } export default function Item({ - id, + icon, title, description, link, + status, linkTitle, email, - isSubscribeForm, + formLink, + value, + isForm, }) { return ( -
+
- { assets && assets.keys().includes(`./${id.toLowerCase()}.svg`) ? : '' } + { assets && assets.keys().includes(`./${icon.toLowerCase()}.svg`) ? : '' }
@@ -37,17 +41,17 @@ export default function Item({
{ - !isSubscribeForm ? ( - { linkTitle } - ) : ( -
+ status && isForm && ( + - +
) } + + { !isForm && { linkTitle }}
); @@ -55,16 +59,22 @@ export default function Item({ Item.defaultProps = { link: '', - isSubscribeForm: false, email: '', + status: '', + value: '', + formLink: '', + isForm: false, }; Item.propTypes = { linkTitle: PT.string.isRequired, title: PT.string.isRequired, description: PT.string.isRequired, + status: PT.string, link: PT.string, - isSubscribeForm: PT.bool, + isForm: PT.bool, + formLink: PT.string, + value: PT.string, email: PT.string, - id: PT.string.isRequired, + icon: PT.string.isRequired, }; diff --git a/src/shared/components/Settings/Preferences/List/Item/styles.scss b/src/shared/components/Settings/Preferences/List/Item/styles.scss index fd32859a0e..39f09efc91 100644 --- a/src/shared/components/Settings/Preferences/List/Item/styles.scss +++ b/src/shared/components/Settings/Preferences/List/Item/styles.scss @@ -11,6 +11,10 @@ background: $tc-white; border: 1px solid $listing-light-gray; border-radius: 8px; + + &.subscribed { + margin-bottom: 0 !important; + } } .item-container:not(:last-child) { diff --git a/src/shared/components/Settings/Preferences/List/data.jsx b/src/shared/components/Settings/Preferences/List/data.jsx index 1e50c56030..53aa8a817a 100644 --- a/src/shared/components/Settings/Preferences/List/data.jsx +++ b/src/shared/components/Settings/Preferences/List/data.jsx @@ -1,11 +1,10 @@ -import forum from 'assets/images/preferences/forum.svg'; import { config } from 'topcoder-react-utils'; const data = [ { id: 'forum', - icon: forum, + icon: 'forum', name: 'Forum', description: 'To setup your forum preferences, please click the “Go To Forum” button.', link: `${config.URL.FORUMS_VANILLA}/profile/preferences`,