CatalogPage.jsx 1.4 KB

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