-
Notifications
You must be signed in to change notification settings - Fork 9
Feat/mentoring-topics-revamp #496
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
Draft
ericbolikowski
wants to merge
28
commits into
master
Choose a base branch
from
feat/mentoring-topics-revamp
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
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 3cd789d
feat(con): create new data lists
ericbolikowski 11c6b6e
feat(connect/mentor profile): refactored mentoring topics
ericbolikowski 9757a65
Merge branch 'master' into feat/mentoring-topics-revamp
ericbolikowski 5e68858
Merge remote-tracking branch 'origin/master' into feat/mentoring-topi…
ericbolikowski 5d665c7
add comment
ericbolikowski c491402
meh
ericbolikowski 117de28
Merge branch 'master' into feat/mentoring-topics-revamp
ericbolikowski 934dcc2
update mentee profile
ericbolikowski db4a4d1
feat: restrict max topics count
ericbolikowski 8368234
remove unused dummy cat
ericbolikowski 9da21a6
reconfigure a couple mentoring topics
ericbolikowski 0ab5f8b
seed script generates value for new RedProfile props
ericbolikowski e20e58d
update mentor listing
ericbolikowski 3cd9333
display group count
ericbolikowski d2d1194
Fix undefined values
katamatata f92466a
Revert "Fix undefined values"
ericbolikowski fd4241c
alternative fix
ericbolikowski e0d5abe
ensure RedProfile of mentee user has no undefined array properties
ericbolikowski 6f07152
Fix mentoringGoals field name with mentor_mentoringGoals
helloanil 84d0034
Fix mentors professionalExperience field, ensure mentee provides requ…
katamatata f8ab464
Mark required and optional fields, fix typos
katamatata 5cd0141
Hide Application page if mentee profile is not complete
katamatata f9f826e
Fixes
katamatata 6b8277c
Fix the blank Applications page for mentors
katamatata ba15b2a
Delete log
katamatata 4165ccf
chore: add missing `as const`
ericbolikowski 92bab92
fix(con): build error through proper type assertion
ericbolikowski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
apps/redi-connect/src/components/molecules/ReadMentoringGoals.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 /> | ||
| ), | ||
| } |
55 changes: 55 additions & 0 deletions
55
apps/redi-connect/src/components/molecules/ReadMentoringTopicsNew2022.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 /> | ||
| ), | ||
| } |
55 changes: 55 additions & 0 deletions
55
apps/redi-connect/src/components/molecules/ReadProfessionalExperienceFields.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
134
apps/redi-connect/src/components/organisms/EditableMentoringGoals.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||
| ) | ||
| } | ||
|
|
||
| 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) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.
🙈 From typescript.react.best-practice.react-props-spreading.react-props-spreading.