Skip to content

Commit 3f50487

Browse files
Merge pull request #1270 from topcoder-platform/PM-2439
PM-2439 Fix year selection in form
2 parents 71c080e + 69a7641 commit 3f50487

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ const ModifyEducationModal: FC<ModifyEducationModalProps> = (props: ModifyEducat
3939
= useState<boolean>(props.education?.length === 0 || false)
4040

4141
const [formValues, setFormValues]: [
42-
{ [key: string]: string | boolean | Date | undefined },
43-
Dispatch<SetStateAction<{ [key: string]: string | boolean | Date | undefined }>>
42+
{ [key: string]: string | boolean | Date | number | undefined },
43+
Dispatch<SetStateAction<{ [key: string]: string | boolean | Date | number | undefined }>>
4444
]
45-
= useState<{ [key: string]: string | boolean | Date | undefined }>({})
45+
= useState<{ [key: string]: string | boolean | Date | number | undefined }>({})
4646

4747
const [formErrors, setFormErrors]: [
4848
{ [key: string]: string },
@@ -91,9 +91,14 @@ const ModifyEducationModal: FC<ModifyEducationModalProps> = (props: ModifyEducat
9191
}
9292

9393
function handleFormValueChange(key: string, event: React.ChangeEvent<HTMLInputElement>): void {
94+
95+
const value = key === 'endYear'
96+
? Number(event.target.value)
97+
: event.target.value
98+
9499
setFormValues({
95100
...formValues,
96-
[key]: event.target.value,
101+
[key]: value,
97102
})
98103
}
99104

@@ -266,11 +271,11 @@ const ModifyEducationModal: FC<ModifyEducationModalProps> = (props: ModifyEducat
266271
/>
267272
<InputSelect
268273
options={yearOptions}
269-
value={`${getYear(formValues.endDate as Date)}`}
270-
onChange={bind(handleFormValueChange, this, 'endDate')}
274+
value={`${Number(formValues.endYear)}`}
275+
onChange={bind(handleFormValueChange, this, 'endYear')}
271276
dirty
272-
error={formErrors.endDate}
273-
name='endDate'
277+
error={formErrors.endYear}
278+
name='endYear'
274279
label='End Year or Expected'
275280
placeholder='Select a year'
276281
tabIndex={0}

0 commit comments

Comments
 (0)