1
1
import { Dispatch , FC , MutableRefObject , SetStateAction , useRef , useState } from 'react'
2
- import { bind , trim } from 'lodash'
2
+ import { bind , range , trim } from 'lodash'
3
3
import { toast } from 'react-toastify'
4
+ import { getYear } from 'date-fns'
4
5
import classNames from 'classnames'
5
6
6
- import { BaseModal , Button , IconOutline , InputDatePicker , InputText } from '~/libs/ui'
7
+ import { BaseModal , Button , IconOutline , InputSelect , InputText } from '~/libs/ui'
7
8
import {
8
9
createMemberTraitsAsync ,
9
10
updateMemberTraitsAsync ,
@@ -29,6 +30,13 @@ const methodsMap: { [key: string]: any } = {
29
30
update : updateMemberTraitsAsync ,
30
31
}
31
32
33
+ const years : number [ ] = range ( 1979 , getYear ( new Date ( ) ) + 10 )
34
+ const yearOptions : any = years
35
+ . map ( v => ( {
36
+ label : `${ v } ` ,
37
+ value : `${ v } ` ,
38
+ } ) )
39
+
32
40
const ModifyEducationModal : FC < ModifyEducationModalProps > = ( props : ModifyEducationModalProps ) => {
33
41
const [ isSaving , setIsSaving ] : [ boolean , Dispatch < SetStateAction < boolean > > ]
34
42
= useState < boolean > ( false )
@@ -92,7 +100,7 @@ const ModifyEducationModal: FC<ModifyEducationModalProps> = (props: ModifyEducat
92
100
93
101
switch ( key ) {
94
102
case 'endDate' :
95
- value = event as unknown as Date
103
+ value = new Date ( event . target . value )
96
104
break
97
105
default :
98
106
value = event . target . value
@@ -188,6 +196,10 @@ const ModifyEducationModal: FC<ModifyEducationModalProps> = (props: ModifyEducat
188
196
189
197
return (
190
198
< BaseModal
199
+ bodyClassName = { styles . eduModalBody }
200
+ classNames = { {
201
+ modal : styles . eduModal ,
202
+ } }
191
203
onClose = { props . onClose }
192
204
open
193
205
size = 'lg'
@@ -270,7 +282,17 @@ const ModifyEducationModal: FC<ModifyEducationModalProps> = (props: ModifyEducat
270
282
onChange = { bind ( handleFormValueChange , this , 'major' ) }
271
283
value = { formValues . major as string }
272
284
/>
273
- < InputDatePicker
285
+ < InputSelect
286
+ options = { yearOptions }
287
+ value = { `${ getYear ( formValues . endDate as Date ) } ` }
288
+ onChange = { bind ( handleFormValueChange , this , 'endDate' ) }
289
+ dirty
290
+ error = { formErrors . endDate }
291
+ name = 'endDate'
292
+ label = 'End Year or Expected'
293
+ placeholder = 'Select a year'
294
+ />
295
+ { /* <InputDatePicker
274
296
label='End date (or expected)'
275
297
date={formValues.endDate as Date}
276
298
onChange={bind(handleFormValueChange, this, 'endDate')}
@@ -280,7 +302,7 @@ const ModifyEducationModal: FC<ModifyEducationModalProps> = (props: ModifyEducat
280
302
showMonthPicker={false}
281
303
showYearPicker
282
304
dateFormat='yyyy'
283
- />
305
+ /> */ }
284
306
</ form >
285
307
) : (
286
308
< Button
0 commit comments