Skip to content

Commit eed2f5f

Browse files
authored
Merge pull request #1253 from topcoder-platform/pm-2066
fix(PM-2066): modifying education and experience in profiles page
2 parents 5d94f8f + 8131b3f commit eed2f5f

File tree

4 files changed

+25
-38
lines changed

4 files changed

+25
-38
lines changed

src/apps/profiles/src/member-profile/education-and-certifications/EducationAndCertifications.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ const EducationAndCertifications: FC<EducationAndCertificationsProps> = (props:
9090
(memberEducation?.length as number) > 0 && (
9191
memberEducation?.map((education: UserTrait) => (
9292
<EducationCard
93-
key={`${education.schoolCollegeName}-${education.major}`}
93+
key={`${education.collegeName}-${education.degree}`}
9494
education={education}
9595
/>
9696
))

src/apps/profiles/src/member-profile/education-and-certifications/EducationCard/EducationCard.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { FC } from 'react'
22
import classNames from 'classnames'
3-
import moment from 'moment'
43

54
import { UserTrait } from '~/libs/core'
65

@@ -16,18 +15,17 @@ const EducationCard: FC<EducationCardProps> = (props: EducationCardProps) => (
1615
<div className={styles.educationCardHeader}>
1716
<div className={styles.educationCardHeaderLeft}>
1817
<p className='body-main-bold'>
19-
{props.education.major}
18+
{props.education.degree}
2019
</p>
2120
<p>
22-
{props.education.schoolCollegeName}
21+
{props.education.collegeName}
2322
</p>
2423
</div>
2524
{
2625
props.education.timePeriodFrom || props.education.timePeriodTo ? (
2726
<div className={styles.educationCardHeaderRight}>
2827
<p>
29-
{props.education.timePeriodTo ? moment(props.education.timePeriodTo)
30-
.format('YYYY') : ''}
28+
{props.education.endYear}
3129
</p>
3230
</div>
3331
) : undefined

src/apps/profiles/src/member-profile/education-and-certifications/ModifyEducationModal/ModifyEducationModal.tsx

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ const ModifyEducationModal: FC<ModifyEducationModalProps> = (props: ModifyEducat
7777
traitId: UserTraitIds.education,
7878
traits: {
7979
data: memberEducation || [],
80+
traitId: UserTraitIds.education,
8081
},
8182
}, props.education)
8283
.then(() => {
@@ -90,20 +91,9 @@ const ModifyEducationModal: FC<ModifyEducationModalProps> = (props: ModifyEducat
9091
}
9192

9293
function handleFormValueChange(key: string, event: React.ChangeEvent<HTMLInputElement>): void {
93-
let value: string | boolean | Date | undefined
94-
95-
switch (key) {
96-
case 'endDate':
97-
value = new Date(event.target.value)
98-
break
99-
default:
100-
value = event.target.value
101-
break
102-
}
103-
10494
setFormValues({
10595
...formValues,
106-
[key]: value,
96+
[key]: event.target.value,
10797
})
10898
}
10999

@@ -118,25 +108,24 @@ const ModifyEducationModal: FC<ModifyEducationModalProps> = (props: ModifyEducat
118108
function handleFormAction(): void {
119109
setFormErrors({})
120110

121-
if (!trim(formValues.schoolCollegeName as string)) {
111+
if (!trim(formValues.collegeName as string)) {
122112
setFormErrors({
123-
schoolCollegeName: 'School is required',
113+
collegeName: 'School is required',
124114
})
125115
return
126116
}
127117

128-
if (!trim(formValues.major as string)) {
118+
if (!trim(formValues.degree as string)) {
129119
setFormErrors({
130-
major: 'Degree is required',
120+
degree: 'Degree is required',
131121
})
132122
return
133123
}
134124

135125
const updatedEducation: UserTrait = {
136-
graduated: formValues.graduated,
137-
major: formValues.major,
138-
schoolCollegeName: formValues.schoolCollegeName,
139-
timePeriodTo: formValues.endDate ? (formValues.endDate as Date).toISOString() : undefined,
126+
collegeName: formValues.collegeName,
127+
degree: formValues.degree,
128+
endYear: formValues.endYear,
140129
}
141130

142131
if (editedItemIndex !== undefined && memberEducation) {
@@ -160,10 +149,9 @@ const ModifyEducationModal: FC<ModifyEducationModalProps> = (props: ModifyEducat
160149
setEditedItemIndex(indx)
161150

162151
setFormValues({
163-
endDate: education.timePeriodTo ? new Date(education.timePeriodTo) : undefined,
164-
graduated: education.graduated,
165-
major: education.major,
166-
schoolCollegeName: education.schoolCollegeName,
152+
collegeName: education.collegeName,
153+
degree: education.degree,
154+
endYear: education.endYear,
167155
})
168156
}
169157

@@ -226,7 +214,7 @@ const ModifyEducationModal: FC<ModifyEducationModalProps> = (props: ModifyEducat
226214
memberEducation?.map((education: UserTrait, indx: number) => (
227215
<div
228216
className={styles.educationCardWrap}
229-
key={`${education.schoolCollegeName}-${education.major}`}
217+
key={`${education.collegeName}-${education.degree}`}
230218
>
231219
<EducationCard education={education} isModalView />
232220
<div className={styles.actionElements}>
@@ -257,24 +245,24 @@ const ModifyEducationModal: FC<ModifyEducationModalProps> = (props: ModifyEducat
257245
<InputText
258246
name='school'
259247
label='Name of College or University *'
260-
error={formErrors.schoolCollegeName}
248+
error={formErrors.collegeName}
261249
placeholder='Enter name of college or university'
262250
dirty
263251
tabIndex={0}
264252
type='text'
265-
onChange={bind(handleFormValueChange, this, 'schoolCollegeName')}
266-
value={formValues.schoolCollegeName as string}
253+
onChange={bind(handleFormValueChange, this, 'collegeName')}
254+
value={formValues.collegeName as string}
267255
/>
268256
<InputText
269-
name='major'
257+
name='degree'
270258
label='Degree *'
271-
error={formErrors.major}
259+
error={formErrors.degree}
272260
placeholder='Enter Degree'
273261
dirty
274262
tabIndex={0}
275263
type='text'
276-
onChange={bind(handleFormValueChange, this, 'major')}
277-
value={formValues.major as string}
264+
onChange={bind(handleFormValueChange, this, 'degree')}
265+
value={formValues.degree as string}
278266
/>
279267
<InputSelect
280268
options={yearOptions}

src/apps/profiles/src/member-profile/work-expirence/ModifyWorkExpirenceModal/ModifyWorkExpirenceModal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ const ModifyWorkExpirenceModal: FC<ModifyWorkExpirenceModalProps> = (props: Modi
7676
traitId: UserTraitIds.work,
7777
traits: {
7878
data: workExpirence || [],
79+
traitId: UserTraitIds.work,
7980
},
8081
}, props.workExpirence)
8182
.then(() => {

0 commit comments

Comments
 (0)