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
2 changes: 1 addition & 1 deletion src/apps/onboarding/src/pages/open-to-work/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export const PageOpenToWorkContent: FC<PageOpenToWorkContentProps> = props => {
try {
const [, updatedTraits] = await Promise.all([
// profile flag
props.updateMemberOpenForWork(formValue.availableForGigs),
props.updateMemberOpenForWork(!!formValue.availableForGigs),

// personalization trait
updateOrCreateMemberTraitsAsync(props.profileHandle, [{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import styles from './OpenForGigs.module.scss'

interface OpenForGigsProps {
canEdit: boolean
isOpenToWork: boolean | null
authProfile: UserProfile | undefined
profile: UserProfile
refreshProfile: (handle: string) => void
Expand All @@ -27,7 +28,7 @@ const OpenForGigs: FC<OpenForGigsProps> = (props: OpenForGigsProps) => {
const [isEditMode, setIsEditMode]: [boolean, Dispatch<SetStateAction<boolean>>]
= useState<boolean>(false)

const openForWork = props.profile.availableForGigs
const openForWork = props.isOpenToWork
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ correctness]
The variable openForWork is now directly assigned from props.isOpenToWork. Ensure that props.isOpenToWork is always correctly initialized and updated, as any null or incorrect value could lead to unexpected UI behavior.


useEffect(() => {
if (props.authProfile && editMode === profileEditModes.openForWork) {
Expand All @@ -53,9 +54,16 @@ const OpenForGigs: FC<OpenForGigsProps> = (props: OpenForGigsProps) => {

return props.canEdit || openForWork || props.isPrivilegedViewer ? (
<div className={styles.container}>
<p className={classNames('body-main-bold', !openForWork ? styles.notOopenToWork : '')}>
{openForWork ? 'open to work' : 'not open to work'}
</p>
{openForWork === null ? (
<p className={classNames('body-main-bold', styles.unknownOopenToWork)}>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[💡 style]
The class name styles.unknownOopenToWork appears to have a typo with 'Oopen'. Verify the class name in the CSS module to ensure it matches the intended styling.

Unknown
</p>
) : (
<p className={classNames('body-main-bold', !openForWork ? styles.notOopenToWork : '')}>
{openForWork ? 'open to work' : 'not open to work'}
</p>
)}

{
props.canEdit && (
<EditMemberPropertyBtn
Expand All @@ -69,6 +77,7 @@ const OpenForGigs: FC<OpenForGigsProps> = (props: OpenForGigsProps) => {
onClose={handleModifyOpenForWorkClose}
onSave={handleModifyOpenForWorkSave}
profile={props.profile}
openForWork={openForWork}
memberPersonalizationTraits={props.memberPersonalizationTraits}
mutatePersonalizationTraits={props.mutatePersonalizationTraits}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface OpenForGigsModifyModalProps {
onClose: () => void
onSave: () => void
profile: UserProfile
openForWork: boolean | null
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ correctness]
The openForWork prop is defined as boolean | null, but it is used directly in the component without handling the null case. Consider providing a default value or handling the null case to avoid potential runtime errors.

memberPersonalizationTraits?: UserTrait[]
mutatePersonalizationTraits: () => void
}
Expand All @@ -34,7 +35,7 @@ const OpenForGigsModifyModal: FC<OpenForGigsModifyModalProps> = (props: OpenForG

const [formValue, setFormValue] = useState<OpenToWorkData>({
availability: undefined,
availableForGigs: !!props.profile.availableForGigs,
availableForGigs: props.openForWork,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ correctness]
The availableForGigs field in the formValue state is directly assigned from props.openForWork, which can be null. Ensure that formValue.availableForGigs is always a boolean to prevent potential issues in components relying on this state.

preferredRoles: [],
})

Expand All @@ -56,12 +57,12 @@ const OpenForGigsModifyModal: FC<OpenForGigsModifyModalProps> = (props: OpenForG
setFormValue(prev => ({
...prev,
availability: openToWorkItem?.availability,
availableForGigs: !!props.profile.availableForGigs,
availableForGigs: props.openForWork,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ correctness]
Similar to the initialization, the availableForGigs field is updated with props.openForWork, which might be null. Ensure that this field is consistently a boolean to maintain predictable behavior.

preferredRoles: openToWorkItem?.preferredRoles ?? [],
}))
}, [
memberPersonalizationTraits,
props.profile.availableForGigs,
props.openForWork,
])

function handleFormChange(nextValue: OpenToWorkData): void {
Expand Down Expand Up @@ -152,8 +153,8 @@ const OpenForGigsModifyModal: FC<OpenForGigsModifyModalProps> = (props: OpenForG
>
<div className={styles.modalBody}>
<p>
By selecting “Open to Work” our talent management team will know
that you are available for engagement opportunities.
By selecting “Open to Work” our customers will know that
you are available for engagement opportunities.
</p>
</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable complexity */
/* eslint-disable unicorn/no-null */
import { Dispatch, FC, SetStateAction, useEffect, useMemo, useState } from 'react'
import { Location, useLocation, useSearchParams } from 'react-router-dom'
import { KeyedMutator } from 'swr'
Expand Down Expand Up @@ -70,7 +71,7 @@ const ProfileHeader: FC<ProfileHeaderProps> = (props: ProfileHeaderProps) => {
[state?.queriedSkills],
)

const activeTooltipText = canEdit ? `You have been active in the past 3 months.
const activeTooltipText = canEdit ? `You have been active in the past 3 months.
(this information is visible to you only)` : `${props.profile.firstName} has been active in the past 3 months.`

useEffect(() => {
Expand Down Expand Up @@ -146,13 +147,15 @@ const ProfileHeader: FC<ProfileHeaderProps> = (props: ProfileHeaderProps) => {
(item: UserTrait) => !!item?.openToWork,
)

const isOpenToWork = hasOpenToWork ? props.profile.availableForGigs : null
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
The variable isOpenToWork is set to null when hasOpenToWork is false. Consider explicitly handling this case where isOpenToWork might be null in the OpenForGigs component to avoid potential runtime errors or unexpected behavior.


function renderOpenForWork(): JSX.Element {
const showMyStatusLabel = canEdit
const showAdminLabel = isPrivilegedViewer

const content = (
<div className={styles.profileActions}>
{showMyStatusLabel && <span>My status:</span>}
{showMyStatusLabel && <span>Engagement status:</span>}

{showAdminLabel && (
<span>
Expand All @@ -169,6 +172,7 @@ const ProfileHeader: FC<ProfileHeaderProps> = (props: ProfileHeaderProps) => {
isPrivilegedViewer={isPrivilegedViewer}
memberPersonalizationTraits={memberPersonalizationTraits}
mutatePersonalizationTraits={mutateTraits}
isOpenToWork={isOpenToWork}
/>
</div>
)
Expand Down
2 changes: 1 addition & 1 deletion src/libs/core/lib/profile/modify-user-profile.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface UpdateProfileRequest {
streetAddr2?: string
zip?: string
}>
availableForGigs?: boolean,
availableForGigs?: boolean | null,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ correctness]
Changing availableForGigs to boolean | null is a significant change. Ensure that all parts of the codebase that handle this property are updated to correctly handle null values. This change could impact logic that assumes a boolean value.

competitionCountryCode?: string
homeCountryCode?: string
email?: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,16 @@
}
}
}

.radioGroup {
display: flex;
margin-bottom: $sp-6;
> * {
flex: 1;
}

@include ltemd {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ correctness]
Ensure that the ltemd mixin is defined and correctly imported. If this mixin is not defined, it could lead to a compilation error.

flex-direction: column;
gap: $sp-4;
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { ChangeEvent, FC, useCallback } from 'react'

import { InputMultiselect, InputMultiselectOption, InputSelect, InputText } from '~/libs/ui'
import { InputMultiselect, InputMultiselectOption, InputRadio, InputSelect } from '~/libs/ui'

import styles from './ModifyOpenToWorkModal.module.scss'

export type AvailabilityType = 'FULL_TIME' | 'PART_TIME'

export interface OpenToWorkData {
availableForGigs: boolean
availableForGigs: boolean | null
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ correctness]
Changing availableForGigs to boolean | null introduces a third state which may not be handled correctly in all parts of the code. Ensure that all logic considering availableForGigs accounts for the null state to avoid potential bugs.

availability?: AvailabilityType
preferredRoles?: string[]
}
Expand Down Expand Up @@ -57,10 +57,12 @@ export const validateOpenToWork = (value: OpenToWorkData): { [key: string]: stri
}

const OpenToWorkForm: FC<OpenToWorkFormProps> = (props: OpenToWorkFormProps) => {
function toggleOpenForWork(): void {
function handleOpenForWorkChange(e: ChangeEvent<HTMLInputElement>): void {
const openForWork = e.target.value === 'true'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
The comparison e.target.value === 'true' relies on string comparison which can be error-prone if the input values change. Consider using a more robust method to parse the boolean value, such as JSON.parse(e.target.value).


props.onChange({
...props.value,
availableForGigs: !props.value.availableForGigs,
availableForGigs: openForWork,
})
}

Expand Down Expand Up @@ -96,20 +98,32 @@ const OpenToWorkForm: FC<OpenToWorkFormProps> = (props: OpenToWorkFormProps) =>

return (
<div className={styles.container}>
<InputText
name='openForWork'
type='checkbox'
label='Yes, I’m open to work'
checked={props.value.availableForGigs}
onChange={toggleOpenForWork}
disabled={props.disabled}
/>
<div className={styles.radioGroup}>
<InputRadio
id='openForWorkYes'
name='openForWork'
value='true'
label="Yes, I'm open to work"
checked={props.value.availableForGigs === true}
onChange={handleOpenForWorkChange}
disabled={props.disabled}
/>
<InputRadio
id='openForWorkNo'
name='openForWork'
value='false'
label="No, I'm not open to work"
checked={props.value.availableForGigs === false}
onChange={handleOpenForWorkChange}
disabled={props.disabled}
/>
</div>

{props.value.availableForGigs && (
<>
<InputSelect
name='availability'
label='Availability'
label='Availability *'
placeholder='Select availability'
options={availabilityOptions}
value={props.value.availability}
Expand All @@ -123,7 +137,7 @@ const OpenToWorkForm: FC<OpenToWorkFormProps> = (props: OpenToWorkFormProps) =>
<InputMultiselect
className={styles.inputMultiSelect}
name='preferredRoles'
label='Preferred Roles'
label='Preferred Roles *'
placeholder='Select preferred roles'
additionalPlaceholder='Add more...'
onFetchOptions={fetchPreferredRoles}
Expand Down
Loading