import { Container } from '@mui/material'; import useMediaQuery from '@mui/material/useMediaQuery'; import { Box } from '@mui/system'; import { useEffect, useState } from 'react'; import { useStore, useStoreUpdate } from '../../../store/cart-context'; import { ProductDataDB } from '../../../utils/interface/productInterface'; import ProductImage from './ProductImage'; import ProductInfo from './ProductInfo'; interface FeaturedProductProps { side: string; bColor: string; product: ProductDataDB; } const FeaturedProduct: React.FC = ({ product, bColor, side, }) => { const matches = useMediaQuery('(min-width: 900px)'); const data = { name: product.name, description: product.description }; const { addCartValue } = useStoreUpdate(); const { cartStorage } = useStore(); const addProductToCart = (quantity: number) => addCartValue(product, quantity); const [inCart, setInCart] = useState(false); useEffect(() => { if (cartStorage.length > 0) { if ( cartStorage?.some((item) => item.product.customID === product.customID) ) setInCart(true); } }, [cartStorage, product.customID]); return ( {side === 'left' ? ( ) : !matches ? ( ) : ( )} {side === 'left' ? ( ) : !matches ? ( ) : ( )} ); }; export default FeaturedProduct;