/** * External dependencies */ import { __ } from '@wordpress/i18n'; import PropTypes from 'prop-types'; /** * Internal dependencies */ import './style.scss'; /** * Display a preview for a given product. */ const ProductPreview = ( { product } ) => { const { placeholderImgSrc } = wc_product_block_data; /* eslint-disable-line camelcase */ let image = null; if ( product.images.length ) { image = ; } else { image = ; } return (
{ image }
{ __( 'Add to cart', 'woo-gutenberg-products-block' ) }
); }; ProductPreview.propTypes = { /** * The product object as returned from the API. */ product: PropTypes.shape( { id: PropTypes.number, images: PropTypes.array, name: PropTypes.string, price_html: PropTypes.string, } ).isRequired, }; export default ProductPreview;