@@ -2,12 +2,18 @@ import React, { useState } from 'react'
2
2
import { Label } from 'reactstrap'
3
3
import Select from 'react-select'
4
4
5
- const EmployerDropDown = ( { employerOnChange , isEmpty, arrayList } ) => {
5
+ const EmployerDropDown = ( { onChange , isEmpty, arrayList, name } ) => {
6
6
const [ value , setValue ] = useState ( '' )
7
7
const employerSorter = ( a , b ) => {
8
8
const aIndex = a . value . toLowerCase ( ) . indexOf ( value . toLowerCase ( ) )
9
9
const bIndex = b . value . toLowerCase ( ) . indexOf ( value . toLowerCase ( ) )
10
- return aIndex > bIndex ? 1 : aIndex < bIndex ? - 1 : 0
10
+ return a . value === 'Other' || b . value === 'Other'
11
+ ? 1
12
+ : aIndex > bIndex
13
+ ? 1
14
+ : aIndex < bIndex
15
+ ? - 1
16
+ : 0
11
17
}
12
18
const employersList = arrayList
13
19
. map ( item => ( {
@@ -16,13 +22,19 @@ const EmployerDropDown = ({ employerOnChange, isEmpty, arrayList }) => {
16
22
} ) )
17
23
. sort ( employerSorter )
18
24
return (
19
- < div className = "form-group" data-testId = "form-group" >
20
- < Label htmlFor = "employer" > Who is your employer?</ Label >
25
+ < div className = "form-group" data-testid = "form-group" >
26
+ < Label htmlFor = "employer" > " Who is your employer? *" </ Label >
21
27
< Select
28
+ className = { `form-control ${ isEmpty && 'is-empty' } ` }
29
+ noOptionsMessage = { ( ) => 'Employer not found? Please select "Other".' }
22
30
inputId = "employer"
23
31
onInputChange = { inputVal => setValue ( inputVal ) }
24
32
options = { employersList }
25
- onChange = { e => employerOnChange ( e . value ) }
33
+ onChange = { e =>
34
+ onChange ( {
35
+ target : { name : 'employer' , type : 'text' , value : e . value }
36
+ } )
37
+ }
26
38
placeholder = "Type your employer name here"
27
39
/>
28
40
</ div >
0 commit comments