Skip to content

Commit 2179f1b

Browse files
authored
Merge pull request #853 from topcoder-platform/MP-307_account-settings-CES-survey
MP-307 - account settings CES sprig survey -> dev
2 parents ba697c5 + d62542d commit 2179f1b

File tree

15 files changed

+46
-6
lines changed

15 files changed

+46
-6
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const SPRIG_CES_SURVEY_ID = 'onAccountSettingsUpdate'

src/apps/accounts/src/config/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './constants'

src/apps/accounts/src/lib/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export * from './accounts-swr'
22
export * from './components'
33
export * from './assets'
4+
export * from './sprig-survey'
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { sprigTriggerForUser } from '~/libs/shared'
2+
import { UserProfile } from '~/libs/core'
3+
4+
import { SPRIG_CES_SURVEY_ID } from '../config'
5+
6+
export function triggerSprigSurvey({ userId }: UserProfile): void {
7+
sprigTriggerForUser(SPRIG_CES_SURVEY_ID, userId)
8+
}

src/apps/accounts/src/settings/tabs/account/account-role/AccountRole.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Dispatch, FC, SetStateAction, useState } from 'react'
22

33
import { BaseModal, Button, Collapsible } from '~/libs/ui'
44
import { authUrlLogout, updatePrimaryMemberRoleAsync, UserProfile } from '~/libs/core'
5+
import { triggerSprigSurvey } from '~/apps/accounts/src/lib'
56

67
import styles from './AccountRole.module.scss'
78

@@ -35,6 +36,7 @@ const AccountRole: FC<AccountRoleProps> = (props: AccountRoleProps) => {
3536
.then(() => {
3637
setMemberRole(newRole)
3738
setIsRoleChangeConfirmed(true)
39+
triggerSprigSurvey(props.profile)
3840
})
3941
.finally(() => {
4042
setIsUpdating(false)

src/apps/accounts/src/settings/tabs/account/address/MemberAddress.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
useCountryLookup,
1414
UserProfile,
1515
} from '~/libs/core'
16+
import { triggerSprigSurvey } from '~/apps/accounts/src/lib'
1617

1718
import styles from './MemberAddress.module.scss'
1819

@@ -87,6 +88,7 @@ const MemberAddress: FC<MemberAddressProps> = (props: MemberAddressProps) => {
8788
.then(() => {
8889
toast.success('Your account has been updated.', { position: toast.POSITION.BOTTOM_RIGHT })
8990
setFormErrors({})
91+
triggerSprigSurvey(props.profile)
9092
})
9193
.catch(() => {
9294
toast.error('Something went wrong. Please try again.', { position: toast.POSITION.BOTTOM_RIGHT })

src/apps/accounts/src/settings/tabs/account/security/Security.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { KeyedMutator } from 'swr'
44
import { noop } from 'lodash'
55

66
import { Button, Collapsible, FormToggleSwitch, IconSolid, Tooltip } from '~/libs/ui'
7-
import { diceIdLogo, MFAImage, SettingSection } from '~/apps/accounts/src/lib'
7+
import { diceIdLogo, MFAImage, SettingSection, triggerSprigSurvey } from '~/apps/accounts/src/lib'
88
import { MemberMFAStatus, updateMemberMFAStatusAsync, useMemberMFAStatus, UserProfile } from '~/libs/core'
99

1010
import { DiceSetupModal } from './dice-setup-modal'
@@ -39,6 +39,7 @@ const Security: FC<SecurityProps> = (props: SecurityProps) => {
3939
.then(() => {
4040
setMFAEnabled(!mfaEnabled)
4141
toast.success('Your Multi Factor Authentication (MFA) status was updated.')
42+
triggerSprigSurvey(props.profile)
4243
})
4344
.catch(() => {
4445
toast.error('Something went wrong. Please try again later.')

src/apps/accounts/src/settings/tabs/account/user-and-pass/UserAndPassword.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
UserTrait,
1818
UserTraits,
1919
} from '~/libs/core'
20-
import { SettingSection } from '~/apps/accounts/src/lib'
20+
import { SettingSection, triggerSprigSurvey } from '~/apps/accounts/src/lib'
2121

2222
import { UserAndPassFromConfig } from './user-and-pass.form.config'
2323
import styles from './UserAndPassword.module.scss'
@@ -82,6 +82,7 @@ const UserAndPassword: FC<UserAndPasswordProps> = (props: UserAndPasswordProps)
8282
setUserConsent(!userConsent)
8383
mutateTraits()
8484
toast.success('User consent updated successfully.')
85+
triggerSprigSurvey(props.profile)
8586
})
8687
.catch(() => {
8788
toast.error('Failed to update user consent.')

src/apps/accounts/src/settings/tabs/preferences/PreferencesTab.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { MemberEmailPreferenceAPI, updateMemberEmailPreferencesAsync, useMemberE
77
import { Button, FormToggleSwitch, LoadingSpinner } from '~/libs/ui'
88
import { EnvironmentConfig } from '~/config'
99

10-
import { EmailIcon, ForumIcon, SettingSection } from '../../../lib'
10+
import { EmailIcon, ForumIcon, SettingSection, triggerSprigSurvey } from '../../../lib'
1111

1212
import { newsletters, programs, subscribeLink, unsubscribeLink } from './preferences.config'
1313
import styles from './PreferencesTab.module.scss'
@@ -43,6 +43,7 @@ const PreferencesTab: FC<PreferencesTabProps> = (props: PreferencesTabProps) =>
4343
.then(() => {
4444
toast.success('Your email preferences ware updated.')
4545
mutateEmailPreferencesData()
46+
triggerSprigSurvey(props.profile)
4647
})
4748
.catch(() => {
4849
toast.error('Something went wrong. Please try again later.')

src/apps/accounts/src/settings/tabs/tcandyou/communities/Communities.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { toast } from 'react-toastify'
55

66
import { updateMemberTraitsAsync, useMemberTraits, UserProfile, UserTraits } from '~/libs/core'
77
import { Button, Collapsible, FormToggleSwitch } from '~/libs/ui'
8+
import { triggerSprigSurvey } from '~/apps/accounts/src/lib'
89

910
import { communitiesConfig } from './communities-config'
1011
import styles from './Communities.module.scss'
@@ -48,6 +49,7 @@ const Communities: FC<CommunitiesProps> = (props: CommunitiesProps) => {
4849
setMemberCommunities(updatedCommunities)
4950
mutateTraits()
5051
toast.success('Communities updated successfully.')
52+
triggerSprigSurvey(props.profile)
5153
})
5254
.catch(() => {
5355
toast.error('Failed to update user Communities.')

0 commit comments

Comments
 (0)