Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
bd1e2c4
docs(connect): remove obselete comment
ericbolikowski Jan 31, 2022
3cd789d
feat(con): create new data lists
ericbolikowski Jan 31, 2022
11c6b6e
feat(connect/mentor profile): refactored mentoring topics
ericbolikowski Mar 7, 2022
9757a65
Merge branch 'master' into feat/mentoring-topics-revamp
ericbolikowski Mar 7, 2022
5e68858
Merge remote-tracking branch 'origin/master' into feat/mentoring-topi…
ericbolikowski Mar 30, 2022
5d665c7
add comment
ericbolikowski Mar 30, 2022
c491402
meh
ericbolikowski Apr 4, 2022
117de28
Merge branch 'master' into feat/mentoring-topics-revamp
ericbolikowski Jun 4, 2022
934dcc2
update mentee profile
ericbolikowski Jun 9, 2022
db4a4d1
feat: restrict max topics count
ericbolikowski Jun 14, 2022
8368234
remove unused dummy cat
ericbolikowski Jun 26, 2022
9da21a6
reconfigure a couple mentoring topics
ericbolikowski Jun 26, 2022
0ab5f8b
seed script generates value for new RedProfile props
ericbolikowski Aug 1, 2022
e20e58d
update mentor listing
ericbolikowski Aug 3, 2022
3cd9333
display group count
ericbolikowski Aug 3, 2022
d2d1194
Fix undefined values
katamatata Nov 3, 2022
f92466a
Revert "Fix undefined values"
ericbolikowski Nov 9, 2022
fd4241c
alternative fix
ericbolikowski Nov 9, 2022
e0d5abe
ensure RedProfile of mentee user has no undefined array properties
ericbolikowski Nov 11, 2022
6f07152
Fix mentoringGoals field name with mentor_mentoringGoals
helloanil Nov 21, 2022
84d0034
Fix mentors professionalExperience field, ensure mentee provides requ…
katamatata Nov 23, 2022
f8ab464
Mark required and optional fields, fix typos
katamatata Dec 1, 2022
5cd0141
Hide Application page if mentee profile is not complete
katamatata Dec 1, 2022
f9f826e
Fixes
katamatata Dec 6, 2022
6b8277c
Fix the blank Applications page for mentors
katamatata Dec 9, 2022
ba15b2a
Delete log
katamatata Dec 9, 2022
4165ccf
chore: add missing `as const`
ericbolikowski Dec 14, 2022
92bab92
fix(con): build error through proper type assertion
ericbolikowski Mar 8, 2023
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
56 changes: 56 additions & 0 deletions apps/redi-connect/src/components/molecules/ReadMentoringGoals.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import {
Caption,
CardTags,
CardTagsProps,
Placeholder,
} from '@talent-connect/shared-atomic-design-components'
import { MENTORING_GOALS } from '@talent-connect/shared-config'
import { RedProfile } from '@talent-connect/shared-types'
import React from 'react'
import { connect } from 'react-redux'
import { RootState } from '../../redux/types'

interface ReadMentoringProps {
profile: RedProfile
caption?: boolean
}

export const ProfileTags = ({ items, shortList }: CardTagsProps) => (
<CardTags
items={items}
shortList={shortList}
formatter={(item: string) => MENTORING_GOALS[item]}
/>
)

const ReadMentoringGoals = ({ profile, caption }: ReadMentoringProps) => {
const { mentoringGoals } = profile

if (!mentoringGoals?.length && !caption)
return (
<Placeholder>
Select at least one goal you would like to support mentees with
</Placeholder>
)

return (
<>
{caption && <Caption>Mentoring goals</Caption>}
<ProfileTags items={mentoringGoals} />
</>
)
}

const mapStateToProps = (state: RootState) => ({
profile: state.user.profile as RedProfile,
})

export default {
Me: connect(mapStateToProps, {})(ReadMentoringGoals),
Some: ({ profile }: ReadMentoringProps) => (
<ReadMentoringGoals profile={profile} caption />
),
Tags: ({ items, shortList }: CardTagsProps) => (
<ProfileTags items={items} shortList />
),
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import {
Caption,
CardTags,
CardTagsProps,
Placeholder,
} from '@talent-connect/shared-atomic-design-components'
import { MENTORING_TOPICS_MAP } from '@talent-connect/shared-config'
import { RedProfile } from '@talent-connect/shared-types'
import React from 'react'
import { connect } from 'react-redux'
import { RootState } from '../../redux/types'

interface ReadMentoringProps {
profile: RedProfile
caption?: boolean
}

export const ProfileTags = ({ items, shortList }: CardTagsProps) => (
<CardTags
items={items}
shortList={shortList}
formatter={(item: string) => MENTORING_TOPICS_MAP[item]}
/>
)

const ReadMentoringTopicsNew2022 = ({
profile,
caption,
}: ReadMentoringProps) => {
const { mentoringTopics } = profile

if (!mentoringTopics?.length && !caption)
return <Placeholder>Please pick mentoring topics.</Placeholder>

return (
<>
{caption && <Caption>{'Mentoring Topics'}</Caption>}
<ProfileTags items={mentoringTopics} />
</>
)
}

const mapStateToProps = (state: RootState) => ({
profile: state.user.profile as RedProfile,
})

export default {
Me: connect(mapStateToProps, {})(ReadMentoringTopicsNew2022),
Some: ({ profile }: ReadMentoringProps) => (
<ReadMentoringTopicsNew2022 profile={profile} caption />
),
Tags: ({ items, shortList }: CardTagsProps) => (
<ProfileTags items={items} shortList />
),
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import {
Caption,
CardTags,
CardTagsProps,
Placeholder,
} from '@talent-connect/shared-atomic-design-components'
import { PROFESSIONAL_EXPERIENCE_FIELDS } from '@talent-connect/shared-config'
import { RedProfile } from '@talent-connect/shared-types'
import React from 'react'
import { connect } from 'react-redux'
import { RootState } from '../../redux/types'

interface ReadMentoringProps {
profile: RedProfile
caption?: boolean
}

export const ProfileTags = ({ items, shortList }: CardTagsProps) => (
<CardTags
items={items}
shortList={shortList}
formatter={(item: string) => PROFESSIONAL_EXPERIENCE_FIELDS[item]}
/>
)

const ReadProfessionalExperienceFields = ({
profile,
caption,
}: ReadMentoringProps) => {
const { professionalExperienceFields } = profile

if (!professionalExperienceFields?.length && !caption)
return <Placeholder>Select your fields of expertise</Placeholder>

return (
<>
{caption && <Caption>Professional experience</Caption>}
<ProfileTags items={professionalExperienceFields} />
</>
)
}

const mapStateToProps = (state: RootState) => ({
profile: state.user.profile as RedProfile,
})

export default {
Me: connect(mapStateToProps, {})(ReadProfessionalExperienceFields),
Some: ({ profile }: ReadMentoringProps) => (
<ReadProfessionalExperienceFields profile={profile} caption />
),
Tags: ({ items, shortList }: CardTagsProps) => (
<ProfileTags items={items} shortList />
),
}
134 changes: 134 additions & 0 deletions apps/redi-connect/src/components/organisms/EditableMentoringGoals.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import {
Checkbox,
Editable,
} from '@talent-connect/shared-atomic-design-components'
import { MENTORING_GOALS } from '@talent-connect/shared-config'
import { RedProfile } from '@talent-connect/shared-types'
import { objectEntries } from '@talent-connect/typescript-utilities'
import { FormikValues, useFormik } from 'formik'
import React from 'react'
import { Content, Element } from 'react-bulma-components'
import { connect } from 'react-redux'
import * as Yup from 'yup'
import { RootState } from '../../redux/types'
import { profileSaveStart } from '../../redux/user/actions'
import ReadMentoringGoals from '../molecules/ReadMentoringGoals'

export interface FormValues {
isMentor: boolean
mentoringGoals: string[]
}

const formMentoringGoals = objectEntries(MENTORING_GOALS)

interface Props {
profile: RedProfile | undefined
profileSaveStart: Function
}

const validationSchema = Yup.object({
mentoringGoals: Yup.array().min(1),
})

const EditableMentoringGoals = ({ profile, profileSaveStart }: Props) => {
const { id, userType, mentoringGoals } = profile as RedProfile

const submitForm = async (values: FormikValues) => {
const profileMentoring = values as Partial<RedProfile>
profileSaveStart({ ...profileMentoring, id })
}

const isMentor =
userType === 'mentor' || userType === 'public-sign-up-mentor-pending-review'

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

const formik = useFormik({
initialValues,
enableReinitialize: true,
validationSchema,
onSubmit: submitForm,
})

const { mentoringGoals: selectedMentoringGoals } = formik.values

const mentoringGoalsChange = (e: any) => {
e.persist()
const value = e.target.value
let newMentoringGoals
if (e.target.checked) {
newMentoringGoals = selectedMentoringGoals.concat(value)
} else {
newMentoringGoals = selectedMentoringGoals.filter(
(cat: any) => cat !== value
)
}
formik.setFieldValue('mentoringGoals', newMentoringGoals)
formik.setFieldTouched('mentoringGoals', true, false)
}

return (
<Editable
title="Mentoring Goals"
onSave={() => formik.handleSubmit()}
onClose={() => formik.resetForm()}
savePossible={formik.dirty && formik.isValid}
read={<ReadMentoringGoals.Me />}
className="mentoring"
>
<Content>
Select at least one goal you would like to support mentees with
</Content>
<Element className="mentoring__group">
{formMentoringGoals.map(([fieldId, fieldLabel]) => (
<MentoringGoal
key={fieldId}
id={fieldId}
label={fieldLabel}
selectedMentoringGoals={selectedMentoringGoals}
onChange={mentoringGoalsChange}
formik={formik}
/>
))}
</Element>
</Editable>
)
}

const MentoringGoal = ({
id,
label,
selectedMentoringGoals,
onChange,
formik,
}: any) => {
return (
<Checkbox.Form
name={`mentoringGoals-${id}`}
key={id}
value={id}
checked={selectedMentoringGoals.includes(id)}
customOnChange={onChange}
{...formik}
>
{label}
</Checkbox.Form>
Comment on lines +113 to +122

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's best practice to explicitly pass props to an HTML component rather than use the spread operator. The spread operator risks passing invalid HTML props to an HTML element, which can cause console warnings or worse, give malicious actors a way to inject unexpected attributes.

⚪️ This finding does not block your pull request.
🙈 From typescript.react.best-practice.react-props-spreading.react-props-spreading.

)
}

const mapStateToProps = (state: RootState) => ({
profile: state.user.profile,
})

const mapDispatchToProps = (dispatch: any) => ({
profileSaveStart: (profile: Partial<RedProfile>) =>
dispatch(profileSaveStart(profile)),
})

export default connect(
mapStateToProps,
mapDispatchToProps
)(EditableMentoringGoals)
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,6 @@ const CategoryGroup = ({
onChange,
formik,
}: any) => {
// The current REDI_LOCATION might not use the current CategoryGroup (e.g.
// Munich doesnt, at the time or writing, use 'coding' or 'other'. If it's the case, return null

if (!categoriesByGroup[id]) return null
return (
<Columns.Column size={4}>
Expand Down
Loading