Skip to content

Commit 2c3feae

Browse files
committed
remove sorting function as is not required and use the default alphapitical sorting
1 parent 5785b9c commit 2c3feae

File tree

1 file changed

+11
-24
lines changed

1 file changed

+11
-24
lines changed

src/Components/forms/inputs/EmployerDropDown.js

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,27 @@
1-
import React, { useState } from 'react'
1+
import React from 'react'
22
import { Label } from 'reactstrap'
33
import Select from 'react-select'
44

5-
const EmployerDropDown = ({ onChange, isEmpty, arrayList, name }) => {
6-
const [value, setValue] = useState('')
7-
const employerSorter = (a, b) => {
8-
const aIndex = a.value.toLowerCase().indexOf(value.toLowerCase())
9-
const bIndex = b.value.toLowerCase().indexOf(value.toLowerCase())
10-
return a.value === 'Other' || b.value === 'Other'
11-
? 1
12-
: aIndex > bIndex
13-
? 1
14-
: aIndex < bIndex
15-
? -1
16-
: 0
17-
}
18-
const employersList = arrayList
19-
.map(item => ({
20-
value: item.name,
21-
label: item.name
22-
}))
23-
.sort(employerSorter)
5+
const EmployerDropDown = ({ onChange, isEmpty, arrayList }) => {
6+
const employersList = arrayList.map(({ _id, name }) => ({
7+
value: _id,
8+
label: name
9+
}))
2410
return (
25-
<div className="form-group" data-testid="form-group">
26-
<Label htmlFor="employer">"Who is your employer? *"</Label>
11+
<div className="form-group">
12+
<Label htmlFor="employer">Who is your employer? *</Label>
2713
<Select
28-
className={`form-control ${isEmpty && 'is-empty'}`}
14+
className={isEmpty ? 'is-empty' : ''}
2915
noOptionsMessage={() => 'Employer not found? Please select "Other".'}
3016
inputId="employer"
31-
onInputChange={inputVal => setValue(inputVal)}
17+
isSearchable
3218
options={employersList}
3319
onChange={e =>
3420
onChange({
3521
target: { name: 'employer', type: 'text', value: e.value }
3622
})
3723
}
24+
name="employer"
3825
placeholder="Type your employer name here"
3926
/>
4027
</div>

0 commit comments

Comments
 (0)