/** * External dependencies */ import { __, sprintf } from '@wordpress/i18n'; import { useEffect, useState } from '@wordpress/element'; import { Button, Card, CardBody, CardFooter, CardHeader, CardMedia, Flex, FlexItem, Icon, Modal, ResponsiveWrapper, } from '@wordpress/components'; import { commentContent, people, reusableBlock } from '@wordpress/icons'; import { Text } from '@woocommerce/experimental'; import { recordEvent } from '@woocommerce/tracks'; /** * Internal dependencies */ import extensionsSvg from './illustration.svg'; import { dismissRequest, remindLaterRequest } from './actions'; export default function ProductUsageNoticeModal( { renewUrl, subscribeUrl, productId, productName, productRegularPrice, dismissAction, dismissNonce, remindLaterAction, remindLaterNonce, subscriptionState, screenId, } ) { const [ isModalOpen, setIsModalOpen ] = useState( true ); useEffect( () => { if ( isModalOpen ) { recordEvent( 'product_usage_notice_opened', { product_id: productId, screen_id: screenId, } ); } }, [ isModalOpen, productId, screenId ] ); const isExpired = subscriptionState.expired; const dismiss = () => { dismissRequest( { dismissAction, productId, dismissNonce, }, () => { setIsModalOpen( false ); recordEvent( 'product_usage_notice_dismissed', { product_id: productId, screen_id: screenId, } ); } ); }; const remindLater = () => { remindLaterRequest( { remindLaterAction, productId, remindLaterNonce, }, () => { setIsModalOpen( false ); recordEvent( 'product_usage_notice_maybe_later_clicked', { product_id: productId, screen_id: screenId, } ); } ); }; const renew = () => { setIsModalOpen( false ); recordEvent( 'product_usage_notice_renew_clicked', { product_id: productId, screen_id: screenId, } ); }; const subscribe = () => { setIsModalOpen( false ); recordEvent( 'product_usage_notice_subscribe_clicked', { product_id: productId, screen_id: screenId, } ); }; const renderBenefits = () => { const subtitle = isExpired ? __( 'Reactivate your subscription and benefit from:', 'woocommerce' ) : __( 'Purchase a subscription to benefit from:', 'woocommerce' ); const benefits = [ { key: 'get-updates', icon: reusableBlock, title: __( 'Improvements and security updates', 'woocommerce' ), content: __( 'Access the latest features and product updates.', 'woocommerce' ), }, { key: 'get-supports', icon: commentContent, title: __( 'Help when you need it', 'woocommerce' ), content: __( 'Get streamlined support from our global support team.', 'woocommerce' ), }, { key: 'supporting-ecosystem', icon: people, title: __( 'Supporting the ecosystem', 'woocommerce' ), content: __( 'A subscription helps us to continuously improve your extensions, themes, and WooCommerce experience.', 'woocommerce' ), }, ]; return (