-
Notifications
You must be signed in to change notification settings - Fork 21
PM-3456 Open to work indicator #1427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ import moment from 'moment' | |
| import { | ||
| NamesAndHandleAppearance, | ||
| UserProfile, | ||
| UserRole, | ||
| } from '~/libs/core' | ||
| import { ProfilePicture, useCheckIsMobile } from '~/libs/shared' | ||
| import { Tooltip } from '~/libs/ui' | ||
|
|
@@ -32,6 +33,17 @@ const ProfileHeader: FC<ProfileHeaderProps> = (props: ProfileHeaderProps) => { | |
| const hasProfilePicture = !!props.profile.photoURL | ||
|
|
||
| const canEdit: boolean = props.authProfile?.handle === props.profile.handle | ||
|
|
||
| const roles = props.authProfile?.roles || [] | ||
|
|
||
| const isPrivilegedViewer | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [💡 |
||
| = !canEdit | ||
| && ( | ||
| roles.includes(UserRole.administrator) | ||
| || roles.includes(UserRole.projectManager) | ||
| || roles.includes(UserRole.talentManager) | ||
| ) | ||
|
|
||
| const canSeeActivityBadge = props.profile.recentActivity | ||
|
|
||
| const [isNameEditMode, setIsNameEditMode]: [boolean, Dispatch<SetStateAction<boolean>>] | ||
|
|
@@ -95,9 +107,20 @@ const ProfileHeader: FC<ProfileHeaderProps> = (props: ProfileHeaderProps) => { | |
| } | ||
|
|
||
| function renderOpenForWork(): JSX.Element { | ||
| const showMyStatusLabel = canEdit | ||
| const showAdminLabel = isPrivilegedViewer | ||
|
|
||
| return ( | ||
| <div className={styles.profileActions}> | ||
| <span>My status:</span> | ||
| {showMyStatusLabel && <span>My status:</span>} | ||
|
|
||
| {showAdminLabel && ( | ||
| <span> | ||
| {props.profile.firstName} | ||
| {' '} | ||
| is | ||
| </span> | ||
| )} | ||
| <OpenForGigs | ||
| canEdit={canEdit} | ||
| authProfile={props.authProfile} | ||
|
|
@@ -201,7 +224,7 @@ const ProfileHeader: FC<ProfileHeaderProps> = (props: ProfileHeaderProps) => { | |
| { | ||
| // Showing only when they can edit until we have the talent search app | ||
| // and enough data to make this useful | ||
| canEdit ? renderOpenForWork() : undefined | ||
| canEdit || isPrivilegedViewer ? renderOpenForWork() : undefined | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [💡 |
||
| } | ||
|
|
||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[❗❗
correctness]The use of
Number(completeness.percent?.toFixed(2))could potentially lead toNaNifcompleteness.percentisnullorundefined. Consider providing a default value to handle such cases, e.g.,Number(completeness.percent?.toFixed(2) || 0). This ensurescompletedis always a valid number.