CatalogPage.jsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import {Container, Grid, useMediaQuery} from "@mui/material";
  2. import {useEffect} from "react";
  3. import Breadcrumb from "../../components/Breadcrumbs";
  4. import {connect} from "react-redux";
  5. import {actionFullAllCategory} from "../../actions/ActionCategory";
  6. import {CategoryAside} from "./CategoryAside";
  7. import {Products} from "./Goods";
  8. const CatalogPage = ({category, actionRootCat}) => {
  9. const matches = useMediaQuery('(max-width:899px)')
  10. useEffect(() => {
  11. if(!category) actionRootCat()
  12. }, [category])
  13. return (
  14. <>
  15. <Breadcrumb links={['catalog']}/>
  16. <main
  17. style={{
  18. backgroundColor: "#f3f3f3",
  19. padding: matches ? "20px 0" : "50px 0",
  20. minHeight: '300px'
  21. }}
  22. >
  23. <Container maxWidth="lg">
  24. <Grid container justifyContent='space-between'>
  25. {category?.payload && <CategoryAside category={category.payload}/>}
  26. <Products/>
  27. </Grid>
  28. </Container>
  29. </main>
  30. </>
  31. )
  32. }
  33. export const CCatalogPage = connect(state => ({category: state.promise['allCategory']}),
  34. {actionRootCat: actionFullAllCategory})(CatalogPage)