Skip to content

Commit e87c03e

Browse files
authored
Merge pull request #859 from topcoder-platform/dev
Member Profiles - BAU Sprint 6
2 parents 9845d56 + 58e683d commit e87c03e

File tree

41 files changed

+514
-437
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+514
-437
lines changed

Diff for: .environments/.env.prod

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ REACT_APP_DATADOG_PUBLIC_TOKEN=puba0825671e469d16f940c5a30dc738f11
1414

1515
REACT_APP_MEMBER_VERIFY_LOOKER=3322
1616

17-
REACT_APP_SPRIG_ENV_ID=bUcousVQ0-yF
17+
REACT_APP_SPRIG_ENV_ID=a-IZBZ6-r7bU
1818

1919
# Filestack configuration for uploading Submissions
2020
REACT_APP_FILESTACK_API_KEY=

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from '~/libs/ui'
1212
import {
1313
updateMemberPasswordAsync,
14-
updateMemberTraitsAsync,
14+
updateOrCreateMemberTraitsAsync,
1515
useMemberTraits,
1616
UserProfile,
1717
UserTrait,
@@ -69,7 +69,7 @@ const UserAndPassword: FC<UserAndPasswordProps> = (props: UserAndPasswordProps)
6969
}
7070

7171
function handleUserConsentChange(): void {
72-
updateMemberTraitsAsync(props.profile.handle, [{
72+
updateOrCreateMemberTraitsAsync(props.profile.handle, [{
7373
categoryName: 'Personalization',
7474
traitId: 'personalization',
7575
traits: {

Diff for: src/apps/accounts/src/settings/tabs/tcandyou/communities/Communities.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { bind } from 'lodash'
33
import { KeyedMutator } from 'swr'
44
import { toast } from 'react-toastify'
55

6-
import { updateMemberTraitsAsync, useMemberTraits, UserProfile, UserTraits } from '~/libs/core'
6+
import { updateOrCreateMemberTraitsAsync, useMemberTraits, UserProfile, UserTraits } from '~/libs/core'
77
import { Button, Collapsible, FormToggleSwitch } from '~/libs/ui'
88
import { triggerSprigSurvey } from '~/apps/accounts/src/lib'
99

@@ -38,7 +38,7 @@ const Communities: FC<CommunitiesProps> = (props: CommunitiesProps) => {
3838
[communityId]: !memberCommunities?.[communityId],
3939
}
4040

41-
updateMemberTraitsAsync(props.profile.handle, [{
41+
updateOrCreateMemberTraitsAsync(props.profile.handle, [{
4242
categoryName: 'Communities',
4343
traitId: 'communities',
4444
traits: {

Diff for: src/apps/accounts/src/settings/tabs/tools/devices/Devices.tsx

+2-7
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { toast } from 'react-toastify'
55
import classNames from 'classnames'
66

77
import {
8-
createMemberTraitsAsync,
98
updateMemberTraitsAsync,
9+
updateOrCreateMemberTraitsAsync,
1010
useMemberDevicesLookup,
1111
UserProfile,
1212
UserTrait,
@@ -31,11 +31,6 @@ interface DevicesProps {
3131
profile: UserProfile
3232
}
3333

34-
const methodsMap: { [key: string]: any } = {
35-
create: createMemberTraitsAsync,
36-
update: updateMemberTraitsAsync,
37-
}
38-
3934
const Devices: FC<DevicesProps> = (props: DevicesProps) => {
4035
const formElRef: MutableRefObject<HTMLDivElement | any> = useRef()
4136

@@ -293,7 +288,7 @@ const Devices: FC<DevicesProps> = (props: DevicesProps) => {
293288
setIsEditMode(false)
294289
})
295290
} else {
296-
methodsMap[!deviceTypesData || !deviceTypesData.length ? 'create' : 'update'](
291+
updateOrCreateMemberTraitsAsync(
297292
props.profile.handle,
298293
[{
299294
categoryName: 'Device',

Diff for: src/apps/accounts/src/settings/tabs/tools/service-provider/ServiceProvider.tsx

+2-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { bind, isEmpty, reject, trim } from 'lodash'
33
import { toast } from 'react-toastify'
44
import classNames from 'classnames'
55

6-
import { createMemberTraitsAsync, updateMemberTraitsAsync, UserProfile, UserTrait } from '~/libs/core'
6+
import { updateMemberTraitsAsync, updateOrCreateMemberTraitsAsync, UserProfile, UserTrait } from '~/libs/core'
77
import { Button, Collapsible, ConfirmModal, IconOutline, InputSelect, InputText } from '~/libs/ui'
88
import {
99
FinancialInstitutionIcon,
@@ -23,11 +23,6 @@ interface ServiceProviderProps {
2323
profile: UserProfile
2424
}
2525

26-
const methodsMap: { [key: string]: any } = {
27-
create: createMemberTraitsAsync,
28-
update: updateMemberTraitsAsync,
29-
}
30-
3126
const ServiceProvider: FC<ServiceProviderProps> = (props: ServiceProviderProps) => {
3227
const formElRef: MutableRefObject<HTMLDivElement | any> = useRef()
3328

@@ -166,7 +161,7 @@ const ServiceProvider: FC<ServiceProviderProps> = (props: ServiceProviderProps)
166161
setIsEditMode(false)
167162
})
168163
} else {
169-
methodsMap[!serviceProviderTypesData || !serviceProviderTypesData.length ? 'create' : 'update'](
164+
updateOrCreateMemberTraitsAsync(
170165
props.profile.handle,
171166
[{
172167
categoryName: 'Service Provider',

Diff for: src/apps/accounts/src/settings/tabs/tools/software/Software.tsx

+2-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { bind, isEmpty, reject, trim } from 'lodash'
33
import { toast } from 'react-toastify'
44
import classNames from 'classnames'
55

6-
import { createMemberTraitsAsync, updateMemberTraitsAsync, UserProfile, UserTrait } from '~/libs/core'
6+
import { updateMemberTraitsAsync, updateOrCreateMemberTraitsAsync, UserProfile, UserTrait } from '~/libs/core'
77
import { Button, Collapsible, ConfirmModal, IconOutline, InputSelect, InputText } from '~/libs/ui'
88
import { SettingSection, SoftwareIcon, triggerSprigSurvey } from '~/apps/accounts/src/lib'
99

@@ -15,11 +15,6 @@ interface SoftwareProps {
1515
profile: UserProfile
1616
}
1717

18-
const methodsMap: { [key: string]: any } = {
19-
create: createMemberTraitsAsync,
20-
update: updateMemberTraitsAsync,
21-
}
22-
2318
const Software: FC<SoftwareProps> = (props: SoftwareProps) => {
2419
const formElRef: MutableRefObject<HTMLDivElement | any> = useRef()
2520

@@ -154,7 +149,7 @@ const Software: FC<SoftwareProps> = (props: SoftwareProps) => {
154149
setIsEditMode(false)
155150
})
156151
} else {
157-
methodsMap[!softwareTypesData || !softwareTypesData.length ? 'create' : 'update'](
152+
updateOrCreateMemberTraitsAsync(
158153
props.profile.handle,
159154
[{
160155
categoryName: 'Software',

Diff for: src/apps/accounts/src/settings/tabs/tools/subscriptions/Subscriptions.tsx

+2-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { bind, isEmpty, reject, trim } from 'lodash'
33
import { toast } from 'react-toastify'
44
import classNames from 'classnames'
55

6-
import { createMemberTraitsAsync, updateMemberTraitsAsync, UserProfile, UserTrait } from '~/libs/core'
6+
import { updateMemberTraitsAsync, updateOrCreateMemberTraitsAsync, UserProfile, UserTrait } from '~/libs/core'
77
import { Button, Collapsible, ConfirmModal, IconOutline, InputText } from '~/libs/ui'
88
import { SettingSection, SubscriptionsIcon, triggerSprigSurvey } from '~/apps/accounts/src/lib'
99

@@ -14,11 +14,6 @@ interface SubscriptionsProps {
1414
profile: UserProfile
1515
}
1616

17-
const methodsMap: { [key: string]: any } = {
18-
create: createMemberTraitsAsync,
19-
update: updateMemberTraitsAsync,
20-
}
21-
2217
const Subscriptions: FC<SubscriptionsProps> = (props: SubscriptionsProps) => {
2318
const formElRef: MutableRefObject<HTMLDivElement | any> = useRef()
2419

@@ -139,7 +134,7 @@ const Subscriptions: FC<SubscriptionsProps> = (props: SubscriptionsProps) => {
139134
setIsEditMode(false)
140135
})
141136
} else {
142-
methodsMap[!subscriptionsTypesData || !subscriptionsTypesData.length ? 'create' : 'update'](
137+
updateOrCreateMemberTraitsAsync(
143138
props.profile.handle,
144139
[{
145140
categoryName: 'Subscription',

Diff for: src/apps/learn/src/tca-certificate/user-certification-view/UserCertificationViewBase.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
SetStateAction,
66
useEffect,
77
useLayoutEffect,
8+
useMemo,
89
useRef,
910
useState,
1011
} from 'react'
@@ -44,6 +45,11 @@ const UserCertificationViewBase: FC<UserCertificationViewBaseProps> = (props: Us
4445
const isOwnProfile: boolean = !!props.profile?.email
4546

4647
const isModalView: boolean = queryParams.get('view-style') === 'modal'
48+
const userName = useMemo(() => (
49+
!!(props.profile?.firstName || props.profile?.lastName)
50+
? `${props.profile.firstName} ${props.profile.lastName}`
51+
: props.enrollment?.userName
52+
), [props.profile, props.enrollment])
4753

4854
const [isMemberVerified, setIsMemberVerified]: [boolean, Dispatch<SetStateAction<boolean>>]
4955
= useState<boolean>(false)
@@ -95,7 +101,7 @@ const UserCertificationViewBase: FC<UserCertificationViewBaseProps> = (props: Us
95101
completionUuid={props.enrollment.completionUuid ?? undefined}
96102
isMemberVerified={isMemberVerified}
97103
userProfile={props.profile}
98-
userName={props.enrollment.userName}
104+
userName={userName}
99105
isOwner={isOwnProfile}
100106
validationUrl={validationUrl}
101107
isPreview={props.isPreview}

Diff for: src/apps/profiles/src/lib/helpers.ts

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ export function subTrackLabelToHumanName(label: string): string {
7171
return 'Development'
7272
case 'ARCHITECTURE':
7373
return 'Architecture'
74+
case 'UI_PROTOTYPE_COMPETITION':
75+
return 'UI Prototype Competition'
7476

7577
default: return label
7678
}

Diff for: src/apps/profiles/src/member-profile/MemberProfilePage.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const MemberProfilePage: FC<{}> = () => {
3131
if (routeParams.memberHandle) {
3232
profileGetPublicAsync(routeParams.memberHandle)
3333
.then(userProfile => {
34-
setProfile(userProfile)
34+
setProfile({ ...userProfile } as UserProfile)
3535
setProfileReady(true)
3636
})
3737
// TODO: NOT FOUND PAGE redirect/dispaly
@@ -41,7 +41,7 @@ const MemberProfilePage: FC<{}> = () => {
4141
const refreshProfile = useCallback((handle: string) => (
4242
profileGetPublicAsync(handle)
4343
.then(userProfile => {
44-
setProfile(userProfile)
44+
setProfile({ ...userProfile } as UserProfile)
4545
if (userProfile) {
4646
notifyUniNavi(userProfile)
4747
triggerSprigSurvey(userProfile)

Diff for: src/apps/profiles/src/member-profile/about-me/ModifyAboutMeModal/ModifyAboutMeModal.tsx

+2-8
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import { toast } from 'react-toastify'
44

55
import { BaseModal, Button, InputText, InputTextarea } from '~/libs/ui'
66
import {
7-
createMemberTraitsAsync,
87
updateMemberProfileAsync,
9-
updateMemberTraitsAsync,
8+
updateOrCreateMemberTraitsAsync,
109
UserProfile,
1110
UserTrait,
1211
UserTraitCategoryNames,
@@ -22,11 +21,6 @@ interface ModifyAboutMeModalProps {
2221
memberPersonalizationTraitsData: UserTrait[] | undefined
2322
}
2423

25-
const methodsMap: { [key: string]: any } = {
26-
create: createMemberTraitsAsync,
27-
update: updateMemberTraitsAsync,
28-
}
29-
3024
const ModifyAboutMeModal: FC<ModifyAboutMeModalProps> = (props: ModifyAboutMeModalProps) => {
3125
const [memberTitle, setMemberTitle]: [
3226
string | undefined,
@@ -79,7 +73,7 @@ const ModifyAboutMeModal: FC<ModifyAboutMeModalProps> = (props: ModifyAboutMeMod
7973
props.profile.handle,
8074
{ description: updatedDescription },
8175
),
82-
methodsMap[!!props.memberPersonalizationTraitsData ? 'update' : 'create'](props.profile.handle, [{
76+
updateOrCreateMemberTraitsAsync(props.profile.handle, [{
8377
categoryName: UserTraitCategoryNames.personalization,
8478
traitId: UserTraitIds.personalization,
8579
traits: {

Diff for: src/apps/profiles/src/member-profile/education-and-certifications/EducationAndCertifications.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
import { EDIT_MODE_QUERY_PARAM, profileEditModes } from '../../config'
1515
import { AddButton, EditMemberPropertyBtn, EmptySection } from '../../components'
1616
import { MemberTCAInfo } from '../tca-info'
17-
import { notifyUniNavi, triggerSprigSurvey } from '../../lib'
17+
import { triggerSprigSurvey } from '../../lib'
1818

1919
import { ModifyEducationModal } from './ModifyEducationModal'
2020
import { EducationCard } from './EducationCard'
@@ -23,6 +23,7 @@ import styles from './EducationAndCertifications.module.scss'
2323
interface EducationAndCertificationsProps {
2424
profile: UserProfile
2525
authProfile: UserProfile | undefined
26+
refreshProfile: (handle: string) => void
2627
}
2728

2829
const EducationAndCertifications: FC<EducationAndCertificationsProps> = (props: EducationAndCertificationsProps) => {
@@ -70,7 +71,7 @@ const EducationAndCertifications: FC<EducationAndCertificationsProps> = (props:
7071
setTimeout(() => {
7172
setIsEditMode(false)
7273
mutateTraits()
73-
notifyUniNavi(props.profile)
74+
props.refreshProfile(props.profile.handle)
7475
triggerSprigSurvey(props.profile)
7576
}, 1000)
7677
}

Diff for: src/apps/profiles/src/member-profile/education-and-certifications/ModifyEducationModal/ModifyEducationModal.tsx

+2-8
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import classNames from 'classnames'
66

77
import { BaseModal, Button, IconOutline, InputSelect, InputText } from '~/libs/ui'
88
import {
9-
createMemberTraitsAsync,
10-
updateMemberTraitsAsync,
9+
updateOrCreateMemberTraitsAsync,
1110
UserProfile,
1211
UserTrait,
1312
UserTraitCategoryNames,
@@ -25,11 +24,6 @@ interface ModifyEducationModalProps {
2524
education: UserTrait[] | undefined
2625
}
2726

28-
const methodsMap: { [key: string]: any } = {
29-
create: createMemberTraitsAsync,
30-
update: updateMemberTraitsAsync,
31-
}
32-
3327
const years: number[] = range(1979, getYear(new Date()) + 10)
3428
const yearOptions: any = years
3529
.map(v => ({
@@ -78,7 +72,7 @@ const ModifyEducationModal: FC<ModifyEducationModalProps> = (props: ModifyEducat
7872

7973
setIsSaving(true)
8074

81-
methodsMap[!!props.education ? 'update' : 'create'](props.profile.handle, [{
75+
updateOrCreateMemberTraitsAsync(props.profile.handle, [{
8276
categoryName: UserTraitCategoryNames.education,
8377
traitId: UserTraitIds.education,
8478
traits: {

Diff for: src/apps/profiles/src/member-profile/languages/ModifyLanguagesModal/ModifyLanguagesModal.tsx

+2-8
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import classNames from 'classnames'
55

66
import { BaseModal, Button, IconOutline, InputSelect } from '~/libs/ui'
77
import {
8-
createMemberTraitsAsync,
9-
updateMemberTraitsAsync,
8+
updateOrCreateMemberTraitsAsync,
109
UserProfile,
1110
UserTrait,
1211
UserTraitCategoryNames,
@@ -25,11 +24,6 @@ interface ModifyLanguagesModalProps {
2524
memberLanguages: UserTrait[] | undefined
2625
}
2726

28-
const methodsMap: { [key: string]: any } = {
29-
create: createMemberTraitsAsync,
30-
update: updateMemberTraitsAsync,
31-
}
32-
3327
const ModifyLanguagesModal: FC<ModifyLanguagesModalProps> = (props: ModifyLanguagesModalProps) => {
3428
const formElRef: MutableRefObject<HTMLDivElement | any> = useRef()
3529

@@ -88,7 +82,7 @@ const ModifyLanguagesModal: FC<ModifyLanguagesModalProps> = (props: ModifyLangua
8882

8983
setIsSaving(true)
9084

91-
methodsMap[!!props.memberLanguages ? 'update' : 'create'](props.profile.handle, [{
85+
updateOrCreateMemberTraitsAsync(props.profile.handle, [{
9286
categoryName: UserTraitCategoryNames.languages,
9387
traitId: UserTraitIds.languages,
9488
traits: {

0 commit comments

Comments
 (0)