/** * 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 } ) => { let image = null; if ( product.images.length ) { image = ; } return (
{ image }
{ product.name }
{ __( 'Add to cart', 'woocommerce' ) }
); }; 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;