diff --git a/mailpoet/assets/js/src/common/premium_banner_with_upgrade/premium_banner_with_upgrade.tsx b/mailpoet/assets/js/src/common/premium_banner_with_upgrade/premium_banner_with_upgrade.tsx index a3adbca53a..ef0a86c300 100644 --- a/mailpoet/assets/js/src/common/premium_banner_with_upgrade/premium_banner_with_upgrade.tsx +++ b/mailpoet/assets/js/src/common/premium_banner_with_upgrade/premium_banner_with_upgrade.tsx @@ -1,4 +1,5 @@ -import { ReactNode } from 'react'; +import jQuery from 'jquery'; +import { ReactNode, useState } from 'react'; import { __ } from '@wordpress/i18n'; import { MailPoet } from 'mailpoet'; import { PremiumRequired } from 'common/premium_required/premium_required'; @@ -11,6 +12,7 @@ type Props = { }; const { + adminPluginsUrl, subscribersLimitReached, subscribersLimit, subscribersCount, @@ -49,7 +51,9 @@ export function PremiumBannerWithUpgrade({ let bannerMessage: ReactNode; let ctaButton: ReactNode; - if (anyValidKey && !premiumActive) { + const [loading, setLoading] = useState(false); + + if (hasValidPremiumKey && (!isPremiumPluginInstalled || !premiumActive)) { bannerMessage = getBannerMessage( __( 'Your current MailPoet plan includes advanced features, but they require the MailPoet Premium plugin to be installed and activated.', @@ -57,16 +61,49 @@ export function PremiumBannerWithUpgrade({ ), ); - ctaButton = isPremiumPluginInstalled - ? getCtaButton( - __('Activate MailPoet Premium plugin', 'mailpoet'), - premiumPluginActivationUrl, - '_self', - ) - : getCtaButton( - __('Download MailPoet Premium plugin', 'mailpoet'), - premiumPluginDownloadUrl, - ); + ctaButton = isPremiumPluginInstalled ? ( + + ) : ( + getCtaButton( + __('Download MailPoet Premium plugin', 'mailpoet'), + premiumPluginDownloadUrl, + ) + ); } else if (subscribersLimitReached) { bannerMessage = getBannerMessage( __( diff --git a/mailpoet/assets/js/src/newsletters/campaign_stats/premium_banner.tsx b/mailpoet/assets/js/src/newsletters/campaign_stats/premium_banner.tsx index bb4916040b..3ca67d0b93 100644 --- a/mailpoet/assets/js/src/newsletters/campaign_stats/premium_banner.tsx +++ b/mailpoet/assets/js/src/newsletters/campaign_stats/premium_banner.tsx @@ -2,112 +2,41 @@ import { __ } from '@wordpress/i18n'; import { MailPoet } from 'mailpoet'; import { Button } from 'common/button/button'; import { PremiumRequired } from 'common/premium_required/premium_required'; -import { useState } from 'react'; -import jQuery from 'jquery'; -import ReactStringReplace from 'react-string-replace'; import { withBoundary } from '../../common'; +import { PremiumBannerWithUpgrade } from '../../common/premium_banner_with_upgrade/premium_banner_with_upgrade'; function SkipDisplayingDetailedStats() { - let ctaButton; - let description; + const ctaButton = ( + + ); - const [loading, setLoading] = useState(false); - - if ( - MailPoet.hasValidPremiumKey && - (!MailPoet.isPremiumPluginInstalled || !MailPoet.premiumActive) - ) { - description = ( -
- {__( - 'Your current MailPoet plan includes advanced features, but they require the MailPoet Premium plugin to be installed and activated.', - 'mailpoet', - )} -
- ); - ctaButton = ( - - ); - // If the premium plugin is not installed, we need to provide a download link - if (!MailPoet.isPremiumPluginInstalled) { - ctaButton = ( - - ); - } - } else { - description = ( -- {__( - 'Learn more about your subscribers and optimize your campaigns. See who opened your emails, which links they clicked, and then use the data to make your emails even better. And if you run a WooCommerce store, you’ll also see the revenue earned per email. All starting $10 per month.', - 'mailpoet', - )}{' '} - - {__('Learn more', 'mailpoet')} - - . -
- ); - ctaButton = ( - - ); - } + const description = ( ++ {__( + 'Learn more about your subscribers and optimize your campaigns. See who opened your emails, which links they clicked, and then use the data to make your emails even better. And if you run a WooCommerce store, you’ll also see the revenue earned per email. All starting $10 per month.', + 'mailpoet', + )}{' '} + + {__('Learn more', 'mailpoet')} + + . +
+ ); return (