Skip to content

Commit

Permalink
Fix mentors professionalExperience field, ensure mentee provides requ…
Browse files Browse the repository at this point in the history
…ired information to display list of mentors
  • Loading branch information
katamatata committed Nov 23, 2022
1 parent 6f07152 commit 84d0034
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 8 deletions.
3 changes: 2 additions & 1 deletion apps/redi-connect/src/assets/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@
"profile": {
"notification": {
"pendingMentor": "<strong>Thanks for signing up!</strong> We are reviewing your profile and will send you an email once we're done. Students will be able to apply to become your mentee once your account is active.",
"pendingMentee": "<strong>Thanks for signing up!</strong> Please schedule a time for an onboarding session with us. You find the link in the email you received. You’ll be able to find a mentor once your account is active.",
"pendingMentee": "<strong>Thanks for signing up!</strong> Please schedule a time for an onboarding session with us. You find the link in the email you received. Meanwhile, we encourage you to fill in your profile.",
"missingMentoringGoal": "<strong>Welcome to ReDI Connect!</strong> Please select a mentoring goal and a primary role you would like to be mentored on. You will be able to find a mentor once your profile is complete.",
"deactivatedMentee": "Dear {{ name }}, your ReDI Connect profile has been deactivated by the Career Support Team. This could be for a number of reasons. If you think this has been done by mistake, please contact Paulina at {{ email }}. Thank you!",
"deactivatedMentor": "Dear {{ name }}, your ReDI Connect profile has been deactivated by the Career Support Team. Likely you have not been active for a while. This means you are not visible to prospective mentees. If you want to become active as a mentor again, please contact Miriam at {{ email }}. Speak soon!"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import ReadProfessionalExperienceFields from '../molecules/ReadProfessionalExper

export interface FormValues {
isMentor: boolean
professionalExperienceFields: string[]
mentor_professionalExperienceFields: string[]
}

const formProfessionalExperienceFields = objectEntries(FIELDS_OF_EXPERTISE)
Expand Down Expand Up @@ -46,7 +46,7 @@ const EditableProfessionalExperienceFields = ({

const initialValues: FormValues = {
isMentor,
professionalExperienceFields: professionalExperienceFields || [],
mentor_professionalExperienceFields: professionalExperienceFields || [],
}

const formik = useFormik({
Expand All @@ -55,7 +55,7 @@ const EditableProfessionalExperienceFields = ({
onSubmit: submitForm,
})

const { professionalExperienceFields: selectedProfessionalExperienceFields } =
const { mentor_professionalExperienceFields: selectedProfessionalExperienceFields } =
formik.values

const professionalExperienceFieldsChange = (e: any) => {
Expand All @@ -70,10 +70,10 @@ const EditableProfessionalExperienceFields = ({
selectedProfessionalExperienceFields.filter((cat: any) => cat !== value)
}
formik.setFieldValue(
'professionalExperienceFields',
'mentor_professionalExperienceFields',
newProfessionalExperienceFields
)
formik.setFieldTouched('professionalExperienceFields', true, false)
formik.setFieldTouched('mentor_professionalExperienceFields', true, false)
}

return (
Expand Down
8 changes: 8 additions & 0 deletions apps/redi-connect/src/components/templates/LoggedIn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
import { useTranslation } from 'react-i18next'
import Footer from '../organisms/Footer'
import { RedMatch } from '@talent-connect/shared-types'
import { ensureMenteeProfileIsComplete } from '../../../../redi-connect/src/pages/app/find-a-mentor/utils'

interface Props {
loading: boolean
Expand Down Expand Up @@ -72,6 +73,8 @@ const LoggedIn = ({
history.push(`/app/mentorships/${redMatchId}`)
}

const isMenteeProfileComplete = ensureMenteeProfileIsComplete(profile)

return (
<>
<Navbar />
Expand All @@ -96,6 +99,11 @@ const LoggedIn = ({
{t('loggedInArea.profile.notification.pendingMentor')}
</RediNotification>
)}
{profile.userType === 'mentee' && !isMenteeProfileComplete && (
<RediNotification>
{t('loggedInArea.profile.notification.missingMentoringGoal')}
</RediNotification>
)}
{profile.userType === 'mentee' && !profile.userActivated && (
<RediNotification>
{t('loggedInArea.profile.notification.deactivatedMentee', {
Expand Down
19 changes: 17 additions & 2 deletions apps/redi-connect/src/pages/app/find-a-mentor/FindAMentor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
FieldOfExperienceKey,
} from '@talent-connect/shared-config'
import './FindAMentor.scss'
import { toggleValueInArray } from './utils'
import { toggleValueInArray, ensureMenteeProfileIsComplete } from './utils'
import {
StringParam,
useQueryParams,
Expand Down Expand Up @@ -117,7 +117,9 @@ function FindAMentor({ profile, profileSaveStart }: FindAMentorProps) {
}))
}

if (profile.userActivated !== true) return <LoggedIn />
const isMenteeProfileComplete = ensureMenteeProfileIsComplete(profile)

if (profile.userActivated !== true || !isMenteeProfileComplete) return <LoggedIn />

const eligibleMentors = allFetchedMentors
.filter((mentor) => mentor.currentFreeMenteeSpots > 0)
Expand Down Expand Up @@ -470,6 +472,11 @@ const curriedFilterFunctions = (filters: FiltersValues) => {
},
menteeMentoringGoalCompatibleWithMentor(mentor: RedProfile) {
switch (filters.menteeMentoringGoal) {
/**
* When mentee has one of the following goals from a mentorship,
* we filter the mentors with relevant professional experience with mentee's
* desired roles
*/
case 'tutoringInAParticularSkillTool':
case 'preparationForACertificationInterview':
case 'careerOrientatioPlanning':
Expand All @@ -480,9 +487,15 @@ const curriedFilterFunctions = (filters: FiltersValues) => {
)
return false

/**
* If the mentee has Primary or Secondary Skills selected, we match those
* with the mentor's mentoringTopics to filter mentors. If they are not selected
* we don't filter.
*/
case 'tutoringInAParticularSkillTool':
case 'preparationForACertificationInterview':
if (
allMenteeRoleMentoringTopics.length > 0 &&
!allMenteeRoleMentoringTopics.some((topic) =>
mentor.mentor_mentoringTopics.includes(topic)
)
Expand Down Expand Up @@ -531,12 +544,14 @@ function ensureNoUndefinedArrayPropertiesInProfile(mentor: RedProfile) {
'mentor_mentoringTopics',
'mentor_mentoringGoals',
'mentor_professionalExperienceFields',
'mentee_mentoringGoal',
'mentee_overarchingMentoringTopics',
'mentee_primaryRole_mentoringTopics',
'mentee_secondaryRole_mentoringTopics',
'mentee_toolsAndFrameworks_mentoringTopics',
]


keys.forEach((key) => {
if (mentor[key] === undefined) {
mentor[key] = []
Expand Down
15 changes: 15 additions & 0 deletions apps/redi-connect/src/pages/app/find-a-mentor/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
import { RedProfile } from '@talent-connect/shared-types'

export function toggleValueInArray<T>(array: Array<T>, value: T) {
if (array.includes(value)) return array.filter((val) => val !== value)
else return [...array, value]
}

// Fix for newly registered mentee users:
// Ensuring that a mentee filled their profile with required information before displaying list of mentors
const isString = (value: any) => typeof value === 'string'
const isFulfilledString = (string: any) => isString(string) && string.length > 0

const arrayIsNotEmpty = (array: any) => Array.isArray(array) && array.length > 0
const isObjectValueFulfilled = (objectValue: any) => arrayIsNotEmpty(objectValue) || isFulfilledString(objectValue)

export const ensureMenteeProfileIsComplete = ({ mentee_mentoringGoal, mentee_primaryRole_fieldOfExpertise }: RedProfile) => {
const isMenteeProfileComplete = isObjectValueFulfilled(mentee_mentoringGoal) && isObjectValueFulfilled(mentee_primaryRole_fieldOfExpertise)
return isMenteeProfileComplete
}

0 comments on commit 84d0034

Please sign in to comment.