qualiteer/src/views/Catalog.jsx

45 lines
1.1 KiB
React
Raw Normal View History

2022-05-23 00:24:21 +00:00
import { useEffect, useContext } from "react";
2022-05-17 12:32:04 +00:00
import StoreContext from "../ctx/StoreContext.jsx";
import JobContext from "../ctx/JobContext.jsx";
2022-06-22 00:47:19 +00:00
import CatalogBox from "./components/CatalogBox.jsx";
2022-05-17 12:32:04 +00:00
import TextField from "@mui/material/TextField";
import CatalogSearch from "./components/CatalogSearch.jsx";
export default function Catalog() {
const {
state: jobState,
dispatch: jobDispatch,
jobUpdate,
jobCreate,
} = useContext(JobContext);
const { state: store, updateStore } = useContext(StoreContext);
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-06-22 00:47:19 +00:00
{store.catalog.map((v, i) => (
<CatalogBox key={i} catalogTest={v} />
))}
2022-05-17 12:32:04 +00:00
</div>
);
}