All files / components/Jobs JobsSearchForm.js

100% Statements 17/17
100% Branches 0/0
100% Functions 4/4
100% Lines 17/17

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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80        2x           43x 43x 43x     43x       43x       43x         43x 3x 3x     43x 3x 3x     43x 4x 4x     43x                                                                        
import useLocalStorage from "main/utils/useLocalStorage";
import { Container, Row, Col } from "react-bootstrap";
import GenericDropdown from "main/components/Utils/GenericDropdown";
 
const JobsSearchForm = ({
  updateSortField,
  updateSortDirection,
  updatePageSize,
}) => {
  // Stryker disable all ; testing for specific hard coded lists is just writing the code twice
  const sortFields = ["status", "createdAt", "updatedAt"];
  const sortDirections = ["ASC", "DESC"];
  const pageSizes = ["5", "10", "20", "50", "100", "200", "500"];
  // Stryker restore all
 
  const [sortField, setSortField] = useLocalStorage(
    "JobsSearch.SortField",
    sortFields[0],
  );
  const [sortDirection, setSortDirection] = useLocalStorage(
    "JobsSearch.SortDirection",
    sortDirections[0],
  );
  const [pageSize, setPageSize] = useLocalStorage(
    "JobsSearch.PageSize",
    pageSizes[0],
  );
 
  const doUpdateSortField = (value) => {
    setSortField(value);
    updateSortField(value);
  };
 
  const doUpdateSortDirection = (value) => {
    setSortDirection(value);
    updateSortDirection(value);
  };
 
  const doUpdatePageSize = (value) => {
    setPageSize(value);
    updatePageSize(value);
  };
 
  return (
    <Container>
      <Row>
        <Col md="auto">
          <GenericDropdown
            values={sortFields}
            value={sortField}
            setValue={doUpdateSortField}
            controlId={"JobsSearch.SortField"}
            label="Sort By"
          />
        </Col>
        <Col md="auto">
          <GenericDropdown
            values={sortDirections}
            value={sortDirection}
            setValue={doUpdateSortDirection}
            controlId={"JobsSearch.SortDirection"}
            label="Sort Direction"
          />
        </Col>
        <Col md="auto">
          <GenericDropdown
            values={pageSizes}
            value={pageSize}
            setValue={doUpdatePageSize}
            controlId={"JobsSearch.PageSize"}
            label="Page Size"
          />
        </Col>
      </Row>
    </Container>
  );
};
 
export default JobsSearchForm;