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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | 2x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 15x 1x 1x 15x 1x 1x 15x | import useLocalStorage from "main/utils/useLocalStorage";
import { Container, Row, Col } from "react-bootstrap";
import { quarterRange } from "main/utils/quarterUtilities";
import { useSystemInfo } from "main/utils/systemInfo";
import SingleQuarterDropdown from "main/components/Quarters/SingleQuarterDropdown";
import SingleSubjectDropdown from "main/components/Subjects/SingleSubjectDropdown";
import GenericDropdown from "main/components/Utils/GenericDropdown";
import { useBackend } from "main/utils/useBackend";
 
const UpdatesSearchForm = ({
  updateQuarter,
  updateSubjectArea,
  updateSortField,
  updateSortDirection,
  updatePageSize,
}) => {
  const { data: systemInfo } = useSystemInfo();
 
  // Stryker disable OptionalChaining
  const startQtr = systemInfo?.startQtrYYYYQ || "20211";
  const endQtr = systemInfo?.endQtrYYYYQ || "20214";
  // Stryker enable OptionalChaining
 
  const quarters = quarterRange(startQtr, endQtr);
 
  const {
    data: subjects,
    error: _error,
    status: _status,
  } = useBackend(
    // Stryker disable next-line all : don't test internal caching of React Query
    ["/api/UCSBSubjects/all"],
    // Stryker disable next-line StringLiteral : equivalent mutation, GET is equivalent to "" (default)
    { method: "GET", url: "/api/UCSBSubjects/all" },
    [],
  );
 
  // Stryker disable all ; testing for specific hard coded lists is just writing the code twice
  const sortFields = ["subjectArea", "quarter", "lastUpdate"];
  const sortDirections = ["ASC", "DESC"];
  const pageSizes = ["10", "50", "100", "200", "500"];
  // Stryker restore all
 
  const [quarter, setQuarter] = useLocalStorage(
    "UpdatesSearch.SubjectArea",
    "ALL",
  );
  const [subjectArea, setSubjectArea] = useLocalStorage(
    "UpdatesSearch.Quarter",
    "ALL",
  );
 
  const doUpdateQuarter = (q) => {
    setQuarter(q);
    updateQuarter(q);
  };
 
  const doUpdateSubjectArea = (s) => {
    setSubjectArea(s);
    updateSubjectArea(s);
  };
 
  return (
    <Container>
      <Row>
        <Col md="auto">
          <SingleQuarterDropdown
            quarters={quarters}
            quarter={quarter}
            setQuarter={doUpdateQuarter}
            controlId={"UpdatesSearch.Quarter"}
            showAll={true}
          />
        </Col>
        <Col md="auto">
          <SingleSubjectDropdown
            subjects={subjects}
            subject={subjectArea}
            setSubject={doUpdateSubjectArea}
            controlId={"UpdatesSearch.SubjectArea"}
            showAll={true}
          />
        </Col>
        <Col md="auto">
          <GenericDropdown
            values={sortFields}
            setValue={updateSortField}
            controlId={"UpdatesSearch.SortField"}
            label="Sort By"
          />
        </Col>
        <Col md="auto">
          <GenericDropdown
            values={sortDirections}
            setValue={updateSortDirection}
            controlId={"UpdatesSearch.SortDirection"}
            label="Sort Direction"
          />
        </Col>
        <Col md="auto">
          <GenericDropdown
            values={pageSizes}
            setValue={updatePageSize}
            controlId={"UpdatesSearch.PageSize"}
            label="Page Size"
          />
        </Col>
      </Row>
    </Container>
  );
};
 
export default UpdatesSearchForm;
  |