-
Notifications
You must be signed in to change notification settings - Fork 126
/
SortSelect.jsx
51 lines (46 loc) · 1.03 KB
/
SortSelect.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React from 'react';
import PropTypes from 'prop-types';
import { VaSelect } from '@department-of-veterans-affairs/component-library/dist/react-bindings';
const sortOptions = [
{
label: 'Disability rating ascending',
value: 'ratingPercentage.asc',
},
{
label: 'Disability rating descending',
value: 'ratingPercentage.desc',
},
{
label: 'Effective date ascending',
value: 'effectiveDate.asc',
},
{
label: 'Effective date descending',
value: 'effectiveDate.desc',
},
];
const SortSelect = ({ onSelect, sortBy }) => {
const handleSelect = e => {
onSelect(e.target.value);
};
return (
<VaSelect
error={null}
label="Sort by"
name="sort-by"
value={sortBy}
onVaSelect={handleSelect}
>
{sortOptions.map(({ label, value }, i) => (
<option key={i} value={value}>
{label}
</option>
))}
</VaSelect>
);
};
SortSelect.propTypes = {
sortBy: PropTypes.string,
onSelect: PropTypes.func,
};
export default SortSelect;