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 | 5x 1x 16x 16x 25x 40x 40x 40x 5x 40x 5x 40x 40x | import { useState } from "react";
import BasicLayout from "main/layouts/BasicLayout/BasicLayout";
import GEAreaSearchForm from "main/components/GEAreas/GEAreaSearchForm";
import { hasRole, useCurrentUser } from "main/utils/currentUser";
import { useBackend, useBackendMutation } from "main/utils/useBackend";
import SectionsTable from "main/components/Sections/SectionsTable";
const objectToAxiosParams = (query) => ({
url: "/api/public/primariesge",
params: {
qtr: query.quarter,
area: query.area,
},
});
const LoggedInResults = ({ sectionJSON }) => {
const {
data: schedules,
error: _error,
status: _status,
} = useBackend(
["/api/personalschedules/all"],
{ method: "GET", url: "/api/personalschedules/all" },
[],
);
return (
<SectionsTable
sections={sectionJSON}
schedules={schedules}
includeGeneralEducation={true}
/>
);
};
const LoggedOutResults = ({ sectionJSON }) => (
<SectionsTable
sections={sectionJSON}
schedules={[]}
includeGeneralEducation={true}
/>
);
export default function GeneralEducationSearchPage() {
const { data: currentUser } = useCurrentUser();
const [sectionJSON, setSectionJSON] = useState([]);
const onSuccess = (section) => {
setSectionJSON(section);
};
const mutation = useBackendMutation(
objectToAxiosParams,
{ onSuccess },
// Stryker disable next-line all : hard to set up test for caching
[],
);
async function fetchGESectionJSON(_event, query) {
mutation.mutate(query);
}
const isLoggedIn = hasRole(currentUser, "ROLE_USER");
return (
<BasicLayout>
<div className="pt-2">
<h5>UCSB GE Search</h5>
<GEAreaSearchForm fetchJSON={fetchGESectionJSON} />
{isLoggedIn ? (
<LoggedInResults sectionJSON={sectionJSON} />
) : (
<LoggedOutResults sectionJSON={sectionJSON} />
)}
</div>
</BasicLayout>
);
}
|