2020-06-12 07:17:17 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import PropTypes from 'prop-types';
|
2020-08-20 04:59:52 +00:00
|
|
|
import { recordEvent } from '@woocommerce/tracks';
|
2020-06-12 07:17:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2020-07-28 02:32:58 +00:00
|
|
|
import './style.scss';
|
2020-06-12 07:17:17 +00:00
|
|
|
import { ProductIcon } from '../../components/';
|
2020-08-13 02:05:22 +00:00
|
|
|
import { getInAppPurchaseUrl } from '../../../lib/in-app-purchase';
|
2020-06-12 07:17:17 +00:00
|
|
|
|
|
|
|
const RecommendedExtensionsItem = ( {
|
|
|
|
title,
|
|
|
|
description,
|
|
|
|
url,
|
2020-07-16 05:52:06 +00:00
|
|
|
product,
|
|
|
|
category,
|
2020-06-12 07:17:17 +00:00
|
|
|
} ) => {
|
|
|
|
const onProductClick = () => {
|
|
|
|
recordEvent( 'marketing_recommended_extension', { name: title } );
|
2020-07-28 02:32:58 +00:00
|
|
|
};
|
2020-06-12 07:17:17 +00:00
|
|
|
|
|
|
|
const classNameBase = 'woocommerce-marketing-recommended-extensions-item';
|
|
|
|
const connectURL = getInAppPurchaseUrl( url );
|
|
|
|
|
2020-07-16 05:52:06 +00:00
|
|
|
// Temporary fix to account for different styles between marketing & coupons
|
|
|
|
if ( category === 'coupons' && product === 'automatewoo' ) {
|
|
|
|
product = `automatewoo-alt`;
|
|
|
|
}
|
|
|
|
|
2020-06-12 07:17:17 +00:00
|
|
|
return (
|
2020-07-28 02:32:58 +00:00
|
|
|
<a
|
|
|
|
href={ connectURL }
|
2020-06-12 07:17:17 +00:00
|
|
|
className={ classNameBase }
|
|
|
|
onClick={ onProductClick }
|
|
|
|
>
|
2020-07-16 05:52:06 +00:00
|
|
|
<ProductIcon product={ product } />
|
2020-06-12 07:17:17 +00:00
|
|
|
|
|
|
|
<div className={ `${ classNameBase }__text` }>
|
|
|
|
<h4>{ title }</h4>
|
|
|
|
<p>{ description }</p>
|
|
|
|
</div>
|
|
|
|
</a>
|
2020-07-28 02:32:58 +00:00
|
|
|
);
|
|
|
|
};
|
2020-06-12 07:17:17 +00:00
|
|
|
|
|
|
|
RecommendedExtensionsItem.propTypes = {
|
|
|
|
title: PropTypes.string.isRequired,
|
|
|
|
description: PropTypes.string.isRequired,
|
|
|
|
url: PropTypes.string.isRequired,
|
2020-07-16 05:52:06 +00:00
|
|
|
product: PropTypes.string.isRequired,
|
|
|
|
category: PropTypes.string.isRequired,
|
2020-06-12 07:17:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default RecommendedExtensionsItem;
|