Skip to content

Commit e0bfe3f

Browse files
authored
Merge pull request #1513 from topcoder-platform/PM-4182_open-to-work-tweaks
PM-4182 tweaks for open to work status
2 parents 7c45800 + 2fc98af commit e0bfe3f

File tree

7 files changed

+68
-27
lines changed

7 files changed

+68
-27
lines changed

src/apps/onboarding/src/pages/open-to-work/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export const PageOpenToWorkContent: FC<PageOpenToWorkContentProps> = props => {
116116
try {
117117
const [, updatedTraits] = await Promise.all([
118118
// profile flag
119-
props.updateMemberOpenForWork(formValue.availableForGigs),
119+
props.updateMemberOpenForWork(!!formValue.availableForGigs),
120120

121121
// personalization trait
122122
updateOrCreateMemberTraitsAsync(props.profileHandle, [{

src/apps/profiles/src/member-profile/profile-header/OpenForGigs/OpenForGigs.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import styles from './OpenForGigs.module.scss'
1212

1313
interface OpenForGigsProps {
1414
canEdit: boolean
15+
isOpenToWork: boolean | null
1516
authProfile: UserProfile | undefined
1617
profile: UserProfile
1718
refreshProfile: (handle: string) => void
@@ -27,7 +28,7 @@ const OpenForGigs: FC<OpenForGigsProps> = (props: OpenForGigsProps) => {
2728
const [isEditMode, setIsEditMode]: [boolean, Dispatch<SetStateAction<boolean>>]
2829
= useState<boolean>(false)
2930

30-
const openForWork = props.profile.availableForGigs
31+
const openForWork = props.isOpenToWork
3132

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

5455
return props.canEdit || openForWork || props.isPrivilegedViewer ? (
5556
<div className={styles.container}>
56-
<p className={classNames('body-main-bold', !openForWork ? styles.notOopenToWork : '')}>
57-
{openForWork ? 'open to work' : 'not open to work'}
58-
</p>
57+
{openForWork === null ? (
58+
<p className={classNames('body-main-bold', styles.unknownOopenToWork)}>
59+
Unknown
60+
</p>
61+
) : (
62+
<p className={classNames('body-main-bold', !openForWork ? styles.notOopenToWork : '')}>
63+
{openForWork ? 'open to work' : 'not open to work'}
64+
</p>
65+
)}
66+
5967
{
6068
props.canEdit && (
6169
<EditMemberPropertyBtn
@@ -69,6 +77,7 @@ const OpenForGigs: FC<OpenForGigsProps> = (props: OpenForGigsProps) => {
6977
onClose={handleModifyOpenForWorkClose}
7078
onSave={handleModifyOpenForWorkSave}
7179
profile={props.profile}
80+
openForWork={openForWork}
7281
memberPersonalizationTraits={props.memberPersonalizationTraits}
7382
mutatePersonalizationTraits={props.mutatePersonalizationTraits}
7483
/>

src/apps/profiles/src/member-profile/profile-header/OpenForGigsModifyModal/OpenForGigsModifyModal.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ interface OpenForGigsModifyModalProps {
2222
onClose: () => void
2323
onSave: () => void
2424
profile: UserProfile
25+
openForWork: boolean | null
2526
memberPersonalizationTraits?: UserTrait[]
2627
mutatePersonalizationTraits: () => void
2728
}
@@ -34,7 +35,7 @@ const OpenForGigsModifyModal: FC<OpenForGigsModifyModalProps> = (props: OpenForG
3435

3536
const [formValue, setFormValue] = useState<OpenToWorkData>({
3637
availability: undefined,
37-
availableForGigs: !!props.profile.availableForGigs,
38+
availableForGigs: props.openForWork,
3839
preferredRoles: [],
3940
})
4041

@@ -56,12 +57,12 @@ const OpenForGigsModifyModal: FC<OpenForGigsModifyModalProps> = (props: OpenForG
5657
setFormValue(prev => ({
5758
...prev,
5859
availability: openToWorkItem?.availability,
59-
availableForGigs: !!props.profile.availableForGigs,
60+
availableForGigs: props.openForWork,
6061
preferredRoles: openToWorkItem?.preferredRoles ?? [],
6162
}))
6263
}, [
6364
memberPersonalizationTraits,
64-
props.profile.availableForGigs,
65+
props.openForWork,
6566
])
6667

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

src/apps/profiles/src/member-profile/profile-header/ProfileHeader.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-disable complexity */
2+
/* eslint-disable unicorn/no-null */
23
import { Dispatch, FC, SetStateAction, useEffect, useMemo, useState } from 'react'
34
import { Location, useLocation, useSearchParams } from 'react-router-dom'
45
import { KeyedMutator } from 'swr'
@@ -70,7 +71,7 @@ const ProfileHeader: FC<ProfileHeaderProps> = (props: ProfileHeaderProps) => {
7071
[state?.queriedSkills],
7172
)
7273

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

7677
useEffect(() => {
@@ -146,13 +147,15 @@ const ProfileHeader: FC<ProfileHeaderProps> = (props: ProfileHeaderProps) => {
146147
(item: UserTrait) => !!item?.openToWork,
147148
)
148149

150+
const isOpenToWork = hasOpenToWork ? props.profile.availableForGigs : null
151+
149152
function renderOpenForWork(): JSX.Element {
150153
const showMyStatusLabel = canEdit
151154
const showAdminLabel = isPrivilegedViewer
152155

153156
const content = (
154157
<div className={styles.profileActions}>
155-
{showMyStatusLabel && <span>My status:</span>}
158+
{showMyStatusLabel && <span>Engagement status:</span>}
156159

157160
{showAdminLabel && (
158161
<span>
@@ -169,6 +172,7 @@ const ProfileHeader: FC<ProfileHeaderProps> = (props: ProfileHeaderProps) => {
169172
isPrivilegedViewer={isPrivilegedViewer}
170173
memberPersonalizationTraits={memberPersonalizationTraits}
171174
mutatePersonalizationTraits={mutateTraits}
175+
isOpenToWork={isOpenToWork}
172176
/>
173177
</div>
174178
)

src/libs/core/lib/profile/modify-user-profile.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export interface UpdateProfileRequest {
88
streetAddr2?: string
99
zip?: string
1010
}>
11-
availableForGigs?: boolean,
11+
availableForGigs?: boolean | null,
1212
competitionCountryCode?: string
1313
homeCountryCode?: string
1414
email?: string

src/libs/shared/lib/components/modify-open-to-work-modal/ModifyOpenToWorkModal.module.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,16 @@
2222
}
2323
}
2424
}
25+
26+
.radioGroup {
27+
display: flex;
28+
margin-bottom: $sp-6;
29+
> * {
30+
flex: 1;
31+
}
32+
33+
@include ltemd {
34+
flex-direction: column;
35+
gap: $sp-4;
36+
}
37+
}

src/libs/shared/lib/components/modify-open-to-work-modal/ModifyOpenToWorkModal.tsx

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { ChangeEvent, FC, useCallback } from 'react'
22

3-
import { InputMultiselect, InputMultiselectOption, InputSelect, InputText } from '~/libs/ui'
3+
import { InputMultiselect, InputMultiselectOption, InputRadio, InputSelect } from '~/libs/ui'
44

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

77
export type AvailabilityType = 'FULL_TIME' | 'PART_TIME'
88

99
export interface OpenToWorkData {
10-
availableForGigs: boolean
10+
availableForGigs: boolean | null
1111
availability?: AvailabilityType
1212
preferredRoles?: string[]
1313
}
@@ -57,10 +57,12 @@ export const validateOpenToWork = (value: OpenToWorkData): { [key: string]: stri
5757
}
5858

5959
const OpenToWorkForm: FC<OpenToWorkFormProps> = (props: OpenToWorkFormProps) => {
60-
function toggleOpenForWork(): void {
60+
function handleOpenForWorkChange(e: ChangeEvent<HTMLInputElement>): void {
61+
const openForWork = e.target.value === 'true'
62+
6163
props.onChange({
6264
...props.value,
63-
availableForGigs: !props.value.availableForGigs,
65+
availableForGigs: openForWork,
6466
})
6567
}
6668

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

9799
return (
98100
<div className={styles.container}>
99-
<InputText
100-
name='openForWork'
101-
type='checkbox'
102-
label='Yes, I’m open to work'
103-
checked={props.value.availableForGigs}
104-
onChange={toggleOpenForWork}
105-
disabled={props.disabled}
106-
/>
101+
<div className={styles.radioGroup}>
102+
<InputRadio
103+
id='openForWorkYes'
104+
name='openForWork'
105+
value='true'
106+
label="Yes, I'm open to work"
107+
checked={props.value.availableForGigs === true}
108+
onChange={handleOpenForWorkChange}
109+
disabled={props.disabled}
110+
/>
111+
<InputRadio
112+
id='openForWorkNo'
113+
name='openForWork'
114+
value='false'
115+
label="No, I'm not open to work"
116+
checked={props.value.availableForGigs === false}
117+
onChange={handleOpenForWorkChange}
118+
disabled={props.disabled}
119+
/>
120+
</div>
107121

108122
{props.value.availableForGigs && (
109123
<>
110124
<InputSelect
111125
name='availability'
112-
label='Availability'
126+
label='Availability *'
113127
placeholder='Select availability'
114128
options={availabilityOptions}
115129
value={props.value.availability}
@@ -123,7 +137,7 @@ const OpenToWorkForm: FC<OpenToWorkFormProps> = (props: OpenToWorkFormProps) =>
123137
<InputMultiselect
124138
className={styles.inputMultiSelect}
125139
name='preferredRoles'
126-
label='Preferred Roles'
140+
label='Preferred Roles *'
127141
placeholder='Select preferred roles'
128142
additionalPlaceholder='Add more...'
129143
onFetchOptions={fetchPreferredRoles}

0 commit comments

Comments
 (0)