Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 52 53 54 55 56 57 | 2x 40x 40x 40x 8x 8x 8x 8x 2x 278x 40x 310x 310x | import React, { useState } from "react";
import { Form } from "react-bootstrap";
// showAll is defaulted to false, to ensure the "ALL" option
// doesn't showdown to pre-existing dropdowns
const SingleGEDropdown = ({
areas,
area,
setArea,
controlId,
onChange = null,
label = "GE Area",
showAll = false,
}) => {
const localSearchArea = localStorage.getItem(controlId);
const [AreaState, setAreaState] = useState(
// Stryker disable next-line all : not sure how to test/mock local storage
localSearchArea || area,
);
const handleAreaOnChange = (event) => {
localStorage.setItem(controlId, event.target.value);
setAreaState(event.target.value);
setArea(event.target.value);
if (onChange != null) {
onChange(event);
}
};
areas.sort((a, b) => a.requirementCode.localeCompare(b.requirementCode));
return (
<Form.Group controlId={controlId}>
<Form.Label>{label}</Form.Label>
<Form.Control as="select" value={AreaState} onChange={handleAreaOnChange}>
{showAll && (
<option data-testid={`${controlId}-option-all`} value="ALL">
ALL
</option>
)}
{areas.map(({ requirementCode }) => {
const key = `${controlId}-option-${requirementCode}`;
return (
<option key={key} data-testid={key} value={requirementCode}>
{requirementCode}
</option>
);
})}
</Form.Control>
</Form.Group>
);
};
export default SingleGEDropdown;
|