11/* eslint-disable max-len */
22import { FC } from 'react'
3- import { bind } from 'lodash'
43import { toast } from 'react-toastify'
54
65import { MemberEmailPreferenceAPI , updateMemberEmailPreferencesAsync , useMemberEmailPreferences , UserProfile } from '~/libs/core'
7- import { Button , FormToggleSwitch , LoadingSpinner } from '~/libs/ui'
6+ import { Button } from '~/libs/ui'
87import { EnvironmentConfig } from '~/config'
98
10- import { EmailIcon , ForumIcon , SettingSection , triggerSurvey } from '../../../lib'
9+ import { ForumIcon , SettingSection , triggerSurvey } from '../../../lib'
1110
12- import { newsletters , programs , subscribeLink , unsubscribeLink } from './preferences.config'
11+ import { subscribeLink , unsubscribeLink } from './preferences.config'
1312import styles from './PreferencesTab.module.scss'
1413
1514interface PreferencesTabProps {
@@ -20,40 +19,14 @@ const PreferencesTab: FC<PreferencesTabProps> = (props: PreferencesTabProps) =>
2019 const { data : emailPreferences , mutate : mutateEmailPreferencesData } : MemberEmailPreferenceAPI
2120 = useMemberEmailPreferences ( props . profile . email )
2221
23- const mailChimpFormAction : string = emailPreferences ?. status === 'subscribed' ? unsubscribeLink : subscribeLink
24-
2522 function handleGoToForumPreferences ( ) : void {
2623 window . open ( `https://${ EnvironmentConfig . ENV === 'prod' ? 'discussions' : 'vanilla' } .${ EnvironmentConfig . TC_DOMAIN } /profile/preferences` , '_blank' )
2724 }
2825
29- function handleSubscribtionStatusChange ( ) : void {
30- if ( emailPreferences ?. status === 'subscribed' ) {
31- window . open ( unsubscribeLink , '_self' )
32- } else {
33- window . open ( subscribeLink , '_self' )
34- }
35- }
36-
37- function handleUserEmailPreferencesChange ( id : string ) : void {
38- updateMemberEmailPreferencesAsync ( props . profile . email , {
39- interests : {
40- [ id ] : ! emailPreferences ?. interests [ id ] ,
41- } ,
42- } )
43- . then ( ( ) => {
44- toast . success ( 'Your email preferences ware updated.' )
45- mutateEmailPreferencesData ( )
46- triggerSurvey ( )
47- } )
48- . catch ( ( ) => {
49- toast . error ( 'Something went wrong. Please try again later.' )
50- } )
51- }
52-
5326 return (
5427 < div className = { styles . container } >
5528 < h3 > PLATFORM PREFERENCES</ h3 >
56-
29+
5730 < div className = { styles . content } >
5831 < SettingSection
5932 leftElement = { (
0 commit comments