Skip to content

Commit b3dbe44

Browse files
committed
Onboarding issues
1 parent 4ea438a commit b3dbe44

File tree

16 files changed

+201
-482
lines changed

16 files changed

+201
-482
lines changed

src/apps/onboarding/src/components/DateInput/index.tsx

Lines changed: 0 additions & 89 deletions
This file was deleted.

src/apps/onboarding/src/components/DateInput/styles.module.scss

Lines changed: 0 additions & 77 deletions
This file was deleted.

src/apps/onboarding/src/components/FormField/index.tsx

Lines changed: 0 additions & 53 deletions
This file was deleted.

src/apps/onboarding/src/components/FormField/styles.module.scss

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/apps/onboarding/src/components/modal-add-education/index.tsx

Lines changed: 27 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import { FC, FocusEvent, useEffect, useState } from 'react'
2+
import { getYear, setYear } from 'date-fns'
23
import _ from 'lodash'
34
import classNames from 'classnames'
4-
import moment from 'moment'
55

6-
import { Button, InputText } from '~/libs/ui'
6+
import { Button, InputSelect, InputText } from '~/libs/ui'
77

8-
import DateInput from '../DateInput'
98
import EducationInfo, { emptyEducationInfo } from '../../models/EducationInfo'
10-
import FormField from '../FormField'
119
import OnboardingBaseModal from '../onboarding-base-modal'
1210

1311
import styles from './styles.module.scss'
@@ -19,23 +17,21 @@ interface ModalAddEducationProps {
1917
onEdit?: (educationInfo: EducationInfo) => void
2018
}
2119

20+
const years: number[] = _.range(1979, getYear(new Date()) + 10)
21+
const yearOptions: any = years
22+
.map(v => ({
23+
label: `${v}`,
24+
value: `${v}`,
25+
}))
26+
2227
const ModalAddEducation: FC<ModalAddEducationProps> = (props: ModalAddEducationProps) => {
2328
const [educationInfo, setEducationInfo] = useState(emptyEducationInfo())
2429
const [formErrors, setFormErrors] = useState<any>({
2530
collegeName: undefined,
2631
endDate: undefined,
2732
major: undefined,
28-
startDate: undefined,
2933
})
3034

31-
const validateDate: any = (startDate: Date | undefined, endDate: Date | undefined) => {
32-
const isInValid: any = endDate
33-
&& startDate
34-
&& moment(endDate)
35-
.isSameOrBefore(startDate)
36-
return !isInValid
37-
}
38-
3935
const validateField: any = () => {
4036
const errorTmp: any = {}
4137
if (!educationInfo.collegeName) {
@@ -46,12 +42,6 @@ const ModalAddEducation: FC<ModalAddEducationProps> = (props: ModalAddEducationP
4642
errorTmp.major = 'Required'
4743
}
4844

49-
if (!educationInfo.startDate) {
50-
errorTmp.startDate = 'Required'
51-
} else if (!validateDate(educationInfo.startDate, educationInfo.endDate)) {
52-
errorTmp.startDate = 'Start Date should be before End Date'
53-
}
54-
5545
if (!educationInfo.endDate) {
5646
errorTmp.endDate = 'Required'
5747
}
@@ -129,51 +119,24 @@ const ModalAddEducation: FC<ModalAddEducationProps> = (props: ModalAddEducationP
129119
error={formErrors.major}
130120
/>
131121
</div>
132-
<div className='d-flex gap-16 full-width'>
133-
<div
134-
className='flex-1'
135-
>
136-
<FormField
137-
label='Start Date *'
138-
error={
139-
formErrors.startDate
140-
}
141-
>
142-
<DateInput
143-
value={educationInfo.startDate}
144-
onChange={function onChange(v: Date | null) {
145-
setEducationInfo({
146-
...educationInfo,
147-
startDate: v || undefined,
148-
})
149-
}}
150-
style2
151-
placeholder='Select start date'
152-
/>
153-
</FormField>
154-
</div>
155-
<div
156-
className='flex-1'
157-
>
158-
<FormField
159-
label='End Date or Expected *'
160-
error={
161-
formErrors.endDate
162-
}
163-
>
164-
<DateInput
165-
value={educationInfo.endDate}
166-
onChange={function onChange(v: Date | null) {
167-
setEducationInfo({
168-
...educationInfo,
169-
endDate: v || undefined,
170-
})
171-
}}
172-
style2
173-
placeholder='Select end date'
174-
/>
175-
</FormField>
176-
</div>
122+
<div className='full-width'>
123+
<InputSelect
124+
tabIndex={0}
125+
options={yearOptions}
126+
value={educationInfo.endDate ? `${getYear(educationInfo.endDate)}` : undefined}
127+
onChange={function onChange(event: any) {
128+
setEducationInfo({
129+
...educationInfo,
130+
endDate: setYear(
131+
new Date(),
132+
parseInt(event.target.value, 10),
133+
),
134+
})
135+
}}
136+
name='endDate'
137+
label='End Year or Expected'
138+
placeholder='Select year'
139+
/>
177140
</div>
178141
</div>
179142
</OnboardingBaseModal>

0 commit comments

Comments
 (0)