123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- import {Box, CircularProgress, Divider, Grid, useMediaQuery} from "@mui/material";
- import Link from "react-router-dom/es/Link";
- import {connect} from "react-redux";
- import {CarouselItem} from "./CarouselItem";
- import {ImageItem} from "./ImageItem";
- import {ProductDescription} from "./ProductDescription";
- import {ProductTitle} from "./ProductTitle";
- import {ProductPrice} from "./ProductPrice";
- import {CAddToCart} from "./AddToCart";
- import {CAddToWishList} from "./AddToWishList";
- import {ProductTags} from "./ProductTags";
- import {timeCalc} from "./timeCalc";
- const Goods = ({good}) => {
- const matches = useMediaQuery('(max-width:768px)')
- return (
- good && Object.values(good).length > 0 ?
- <Grid
- container
- justifyContent='space-around'
- padding={matches ? "20px 0" : "50px 0"}
- >
- <Grid xs={12} md={6}
- item
- padding='5px 70px 5px 10px'
- >
- {Array.isArray(good?.images) && good?.images.length > 1 ?
- <CarouselItem images={good?.images}/>
- :
- <Box
- sx={{
- width: '100%',
- display: 'flex',
- justifyContent: 'center',
- height: '340px'
- }}
- >
- <ImageItem images={Array.isArray(good?.images) && good?.images[0]}/>
- </Box>
- }
- <Divider sx={{margin: '20px 0'}}/>
- <ProductDescription description={good?.description}/>
- </Grid>
- <Grid xs={12} md={6}
- item
- padding='5px 110px 5px 10px'
- >
- <ProductTitle title={good?.name}/>
- <ProductPrice price={good?.price}/>
- <CAddToCart good={good}/>
- <CAddToWishList good={good}/>
- <Box>
- {good?._id &&
- <ProductTags
- key={'SKU'}
- title={'SKU'}
- subtitle={good?._id}
- />
- }
- {Array.isArray(good?.categories) &&
- <ProductTags
- key={'CATEGORY'}
- title={'CATEGORY'}
- subtitle={good?.categories.map(item => {
- return (
- <Link
- key={item?._id}
- style={{
- color: "#000",
- textDecoration: 'none'
- }}
- to={`/catalog/category/${item?._id}`}
- >
- {item?.name}
- </Link>
- )
- })}
- />
- }
- {good?.createdAt &&
- <ProductTags
- key={'TIMEOFCREATION'}
- title={'TIME OF CREATION'}
- subtitle={timeCalc(good?.createdAt)}
- />
- }
- </Box>
- </Grid>
- </Grid>:
- <Box
- sx={{
- height: '100%',
- width: '100%',
- display: 'flex',
- justifyContent:'center',
- alignItems:'center'
- }}
- >
- <CircularProgress color="inherit"/>
- </Box>
- )
- }
- export const CGoods = connect(state => ({good: state.promise['goodFindOne']?.payload}))(Goods)
|