Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
font-weight: 900;
}

small {
font-family: $font-roboto;
font-weight: 400;
font-size: 16px;
line-height: 24px;
color: #EF476F;
}

@include ltemd {
font-size: 24px;
line-height: 28px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FC, useEffect } from 'react'
import { FC, useEffect, useMemo } from 'react'
import { startCase } from 'lodash'

import { useProfileCompleteness, UserProfile } from '~/libs/core'

Expand All @@ -21,10 +22,39 @@ const ProfileCompleteness: FC<ProfileCompletenessProps> = props => {

useEffect(() => { completeness?.mutate() }, [props.profile])

const [count, incompleteEntries] = useMemo(() => {
const fields = Object.entries(completeness.entries)
.filter(([, value]) => !value)
.map(([key]) => startCase(key))

if (fields.length === 2) {
return [2, fields.join(' and ')]
}

if (fields.length >= 2) {
fields[fields.length - 1] = `and ${fields[fields.length - 1]}`
}

return [fields.length, fields.join(', ')]
}, [completeness.entries])

return hideCompletenessMeter ? <></> : (
<div className={styles.wrap}>
<strong>Profile: </strong>
{`${completed}% Complete`}
<div>
<small>
Only
{' '}
{incompleteEntries}
{' '}
left to fill. Please add
{' '}
{count === 1 ? 'it' : 'them'}
{' '}
to make your profile more discoverable.
</small>
</div>
</div>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import useSWR, { KeyedMutator, SWRResponse } from 'swr'
import { getProfileUrl } from '../profile-functions'

export function useProfileCompleteness(memberHandle?: string): {
entries: {[key: string]: boolean},
isLoading: boolean,
mutate: KeyedMutator<any>,
percent: number | undefined,
Expand All @@ -13,6 +14,7 @@ export function useProfileCompleteness(memberHandle?: string): {

const percentComplete = data?.data?.percentComplete
return {
entries: data?.data ?? {},
isLoading: percentComplete === undefined,
mutate,
percent: (percentComplete ?? 0) * 100,
Expand Down
Loading