File tree Expand file tree Collapse file tree 4 files changed +23
-12
lines changed
apps/profiles/src/member-profile
libs/core/lib/profile/data-providers Expand file tree Collapse file tree 4 files changed +23
-12
lines changed Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff line change @@ -27,7 +27,6 @@ interface ProfilePageLayoutProps {
2727}
2828
2929const ProfilePageLayout : FC < ProfilePageLayoutProps > = ( props : ProfilePageLayoutProps ) => (
30-
3130 < div className = { styles . container } >
3231
3332 < PageTitle > { `${ props . profile . handle } | Community Profile | Topcoder` } </ PageTitle >
@@ -81,7 +80,7 @@ const ProfilePageLayout: FC<ProfilePageLayoutProps> = (props: ProfilePageLayoutP
8180 </ div >
8281 < div className = { styles . profileInfoRight } >
8382 { props . authProfile ?. handle === props . profile . handle && (
84- < ProfileCompleteness profile = { props . authProfile } />
83+ < ProfileCompleteness profile = { props . profile } authProfile = { props . authProfile } />
8584 ) }
8685 < div className = { styles . sectionWrap } >
8786 < div className = { styles . skillsWrap } >
Original file line number Diff line number Diff line change 1- import { FC } from 'react'
1+ import { FC , useEffect } from 'react'
22
33import { useProfileCompleteness , UserProfile } from '~/libs/core'
44
55import styles from './ProfileCompleteness.module.scss'
66
77interface ProfileCompletenessProps {
88 profile : UserProfile
9+ authProfile : UserProfile
910}
1011
1112const ProfileCompleteness : FC < ProfileCompletenessProps > = props => {
12- const completed = useProfileCompleteness ( props . profile . handle )
13- const isLoading = completed === undefined
13+ const completeness = useProfileCompleteness ( props . profile . handle )
14+ const completed = completeness . percent
15+ const isLoading = completeness . isLoading
1416 const isCompleted = completed === 100
1517
16- const isCustomer = props . profile . roles . some ( r => r . indexOf ( ' Customer' ) > - 1 )
18+ const isCustomer = props . authProfile . roles . some ( r => r . indexOf ( ' Customer' ) > - 1 )
1719
1820 const hideCompletenessMeter = isLoading || isCompleted || isCustomer
1921
22+ useEffect ( ( ) => { completeness ?. mutate ( ) } , [ props . profile ] )
23+
2024 return hideCompletenessMeter ? < > </ > : (
2125 < div className = { styles . wrap } >
2226 < strong > Profile: </ strong >
Original file line number Diff line number Diff line change 1- import useSWR , { SWRResponse } from 'swr'
1+ import useSWR , { KeyedMutator , SWRResponse } from 'swr'
22
33import { getProfileUrl } from '../profile-functions'
44
5- export function useProfileCompleteness ( memberHandle ?: string ) : number | undefined {
6- const { data } : SWRResponse = useSWR ( `${ getProfileUrl ( memberHandle ?? '' ) } /profileCompleteness` , {
5+ export function useProfileCompleteness ( memberHandle ?: string ) : {
6+ isLoading : boolean ,
7+ mutate : KeyedMutator < any > ,
8+ percent : number | undefined ,
9+ } {
10+ const { data, mutate } : SWRResponse = useSWR ( `${ getProfileUrl ( memberHandle ?? '' ) } /profileCompleteness` , {
711 isPaused : ( ) => ! memberHandle ,
812 } )
913
1014 const percentComplete = data ?. data ?. percentComplete
11- return percentComplete === undefined ? percentComplete : ( percentComplete ?? 0 ) * 100
15+ return {
16+ isLoading : percentComplete === undefined ,
17+ mutate,
18+ percent : ( percentComplete ?? 0 ) * 100 ,
19+ }
1220}
You can’t perform that action at this time.
0 commit comments