Refactored frontend

This commit is contained in:
Dunemask 2022-07-12 21:48:05 +00:00
parent 37613e4de1
commit 6386294887
24 changed files with 54 additions and 529 deletions

View file

@ -0,0 +1,45 @@
import { useEffect, useContext } from "react";
import StoreContext from "../../ctx/StoreContext.jsx";
import JobContext from "../../ctx/JobContext.jsx";
import CatalogBox from "./CatalogBox.jsx";
import CatalogSearch from "./CatalogSearch.jsx";
import TextField from "@mui/material/TextField";
export default function Catalog() {
const {
state: jobState,
dispatch: jobDispatch,
jobUpdate,
jobCreate,
} = useContext(JobContext);
const { state: store, updateStore } = useContext(StoreContext);
const handleSearchChange = (e) =>
updateStore({ catalogSearch: e.target.value });
const handleSearchClear = () => updateStore({ catalogSearch: "" });
useEffect(() => {
return function unmount() {
handleSearchClear();
};
}, []);
return (
<div className="catalog">
<CatalogSearch
onChange={handleSearchChange}
onClear={handleSearchClear}
clearOnUnmount
/>
<h6>{store.catalogSearch}</h6>
{store.catalog.map((v, i) => (
<CatalogBox key={i} catalogTest={v} />
))}
</div>
);
}