import React from 'react'; import { Link } from 'react-router-dom'; import { useDispatch } from 'react-redux'; // material-ui import { Button, CardContent, CardMedia, Grid, Rating, Stack, Typography } from '@mui/material'; // project import import MainCard from './MainCard'; import SkeletonProductPlaceholder from 'ui-component/cards/Skeleton/ProductPlaceholder'; import { KeyedObject } from 'types'; import { ADD_PRODUCTS, SNACKBAR_OPEN } from 'store/actions'; // assets import ShoppingCartTwoToneIcon from '@mui/icons-material/ShoppingCartTwoTone'; const prodImage = require.context('assets/images/e-commerce', true); // ==============================|| PRODUCT CARD ||============================== // export interface ProductCardProps extends KeyedObject { id?: string | number; color?: string; name: string; image: string; description?: string; offerPrice?: number; salePrice?: number; rating?: number; } const ProductCard = ({ id, color, name, image, description, offerPrice, salePrice, rating }: ProductCardProps) => { const dispatch = useDispatch(); const prodProfile = image && prodImage(`./${image}`).default; const [productRating] = React.useState(rating); const addCart = () => { dispatch({ type: ADD_PRODUCTS, product: { id, name, image, salePrice, offerPrice, color, size: 8, quantity: 1 } }); dispatch({ type: SNACKBAR_OPEN, open: true, message: 'Add To Cart Success', variant: 'alert', alertSeverity: 'success' }); }; const [isLoading, setLoading] = React.useState(true); React.useEffect(() => { setLoading(false); }, []); return ( <> {isLoading ? ( ) : ( {name} {description && ( {description} )} ({offerPrice}+) ${offerPrice} ${salePrice} )} ); }; export default ProductCard;