Skip to content

Commit bf8d948

Browse files
committed
use onChange intead of employerOnchange
1 parent f9ead46 commit bf8d948

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/Components/forms/inputs/EmployerDropDown.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@ import React, { useState } from 'react'
22
import { Label } from 'reactstrap'
33
import Select from 'react-select'
44

5-
const EmployerDropDown = ({ employerOnChange, isEmpty, arrayList }) => {
5+
const EmployerDropDown = ({ onChange, isEmpty, arrayList, name }) => {
66
const [value, setValue] = useState('')
77
const employerSorter = (a, b) => {
88
const aIndex = a.value.toLowerCase().indexOf(value.toLowerCase())
99
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
1117
}
1218
const employersList = arrayList
1319
.map(item => ({
@@ -16,13 +22,19 @@ const EmployerDropDown = ({ employerOnChange, isEmpty, arrayList }) => {
1622
}))
1723
.sort(employerSorter)
1824
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>
2127
<Select
28+
className={`form-control ${isEmpty && 'is-empty'}`}
29+
noOptionsMessage={() => 'Employer not found? Please select "Other".'}
2230
inputId="employer"
2331
onInputChange={inputVal => setValue(inputVal)}
2432
options={employersList}
25-
onChange={e => employerOnChange(e.value)}
33+
onChange={e =>
34+
onChange({
35+
target: { name: 'employer', type: 'text', value: e.value }
36+
})
37+
}
2638
placeholder="Type your employer name here"
2739
/>
2840
</div>

0 commit comments

Comments
 (0)