Refactored frontend
This commit is contained in:
parent
37613e4de1
commit
6386294887
24 changed files with 54 additions and 529 deletions
45
src/views/catalog/Catalog.jsx
Normal file
45
src/views/catalog/Catalog.jsx
Normal 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>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue