2022-05-23 00:24:21 +00:00
|
|
|
import { useEffect, useContext } from "react";
|
2022-07-12 21:48:05 +00:00
|
|
|
import StoreContext from "../../ctx/StoreContext.jsx";
|
|
|
|
import JobContext from "../../ctx/JobContext.jsx";
|
|
|
|
import CatalogBox from "./CatalogBox.jsx";
|
|
|
|
import CatalogSearch from "./CatalogSearch.jsx";
|
2022-08-09 04:29:10 +00:00
|
|
|
import { useCatalogTests } from "../../Queries.jsx";
|
2022-05-17 12:32:04 +00:00
|
|
|
import TextField from "@mui/material/TextField";
|
|
|
|
|
|
|
|
export default function Catalog() {
|
|
|
|
const { state: store, updateStore } = useContext(StoreContext);
|
2022-08-09 04:29:10 +00:00
|
|
|
const { isLoading, data: tests } = useCatalogTests();
|
2022-05-23 00:24:21 +00:00
|
|
|
const handleSearchChange = (e) =>
|
|
|
|
updateStore({ catalogSearch: e.target.value });
|
|
|
|
|
|
|
|
const handleSearchClear = () => updateStore({ catalogSearch: "" });
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
return function unmount() {
|
|
|
|
handleSearchClear();
|
|
|
|
};
|
|
|
|
}, []);
|
|
|
|
|
2022-05-17 12:32:04 +00:00
|
|
|
return (
|
|
|
|
<div className="catalog">
|
2022-05-23 00:24:21 +00:00
|
|
|
<CatalogSearch
|
|
|
|
onChange={handleSearchChange}
|
|
|
|
onClear={handleSearchClear}
|
|
|
|
clearOnUnmount
|
|
|
|
/>
|
|
|
|
<h6>{store.catalogSearch}</h6>
|
2022-08-09 04:29:10 +00:00
|
|
|
{isLoading
|
|
|
|
? null
|
|
|
|
: tests.map((v, i) => <CatalogBox key={i} catalogTest={v} />)}
|
2022-05-17 12:32:04 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|