WishListPage.jsx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import Breadcrumb from "../components/Breadcrumbs";
  2. import {Box, Container, Divider, Typography, useMediaQuery} from "@mui/material";
  3. import {connect} from 'react-redux';
  4. import {actionWishListRemove} from "../reducers/WishListReducer";
  5. import {actionCardChange} from "../reducers/CartReducer";
  6. import {NotFoundBlock} from "../components/NotFoundBlock";
  7. import imgUrl from "../img/not-found/2.png"
  8. import FavoriteBorderIcon from "@mui/icons-material/FavoriteBorder";
  9. import {TableLine} from "../components/TableLine";
  10. const MainWishList = ({wishlist, addToCart, onWishListRemove, color='#f3f3f3'}) => {
  11. const matches = useMediaQuery('(max-width:899px)')
  12. let rows = []
  13. for (const key of Object.values(wishlist)) {
  14. for (const item in key) {
  15. rows.push(key[item])
  16. }
  17. }
  18. return (
  19. <>
  20. {Object.values(wishlist).length > 0 ?
  21. <main style={{backgroundColor: {color}, padding: matches ? "20px 0" : "50px 0"}}>
  22. <Container maxWidth="lg">
  23. <TableLine columnName={['PRODUCT', 'PRICE', 'REMOVE', 'ADD TO CART']}/>
  24. <Divider sx={{marginBottom: '20px'}}/>
  25. {rows.map(item => <TableLine columnName={[[item?._id, item?.name, item?.images], item?.price, onWishListRemove, addToCart]} role={'item'}/>)}
  26. <Divider/>
  27. </Container>
  28. </main> :
  29. <NotFoundBlock img={imgUrl} headerText={'YOUR WISHLIST IS CURRENTLY EMPTY'} text={<Box display='flex' alignItems='center'><Typography component='span'>Click the</Typography><FavoriteBorderIcon sx={{margin: '0 10px'}}/><Typography component='span'>icons to add products</Typography></Box>}/>
  30. }
  31. </>
  32. )
  33. }
  34. export const CMainWishList = connect(state => ({wishlist: state.wishlist}), {addToCart: actionCardChange, onWishListRemove: actionWishListRemove})(MainWishList)
  35. const WishListPage = () => {
  36. return (
  37. <>
  38. <Breadcrumb links={['wish list']}/>
  39. <CMainWishList/>
  40. </>
  41. )
  42. }
  43. export default WishListPage
  44. // TODO MOBILE VERSION