AddonRowActions.jsx
6 days ago
AddonsList.jsx
6 days ago
AllAccessAddonsSummary.jsx
6 days ago
AutoUpdateModal.jsx
6 days ago
DownloadActivateButton.jsx
6 days ago
EmptyState.jsx
6 days ago
FeatureList.jsx
6 days ago
LicenseField.jsx
6 days ago
LicenseItem.jsx
6 days ago
LicenseNotices.jsx
6 days ago
LicenseStatus.jsx
6 days ago
Loader.jsx
6 days ago
PricingModal.jsx
6 days ago
PricingTable.jsx
6 days ago
PricingTableItem.jsx
6 days ago
SitesModal.jsx
6 days ago
EmptyState.jsx
77 lines
| 1 | /** |
| 2 | * External Dependencies |
| 3 | */ |
| 4 | import { __ } from '@wordpress/i18n'; |
| 5 | import { useModalState } from '@admin/hooks/useModalState'; |
| 6 | import { PLANS } from './PricingTable'; |
| 7 | import { startShopCheckoutForPlan } from '../utils'; |
| 8 | import { PricingModal } from './PricingModal'; |
| 9 | |
| 10 | export function EmptyState() { |
| 11 | const { |
| 12 | isOpen: isPricingOpen, |
| 13 | open: openModal, |
| 14 | close: handlePricingClose, |
| 15 | } = useModalState(); |
| 16 | |
| 17 | const handlePricingOpen = () => { |
| 18 | const utmUrl = `${ advancedAds.endpoints.shopUrl }/?utm_source=advancedads&utm_medium=in-plugin&utm_campaign=a2-in_plugin-licenses_addons-buy-no_licenses`; |
| 19 | |
| 20 | // 1. Fire the UTM "ping" in the background |
| 21 | // 'no-cors' prevents errors if the shop is on a different domain |
| 22 | // 'keepalive' ensures the request finishes even if the modal opens/state changes |
| 23 | fetch( utmUrl, { mode: 'no-cors', keepalive: true } ); |
| 24 | |
| 25 | // 2. Open the modal |
| 26 | openModal(); |
| 27 | }; |
| 28 | |
| 29 | const handleSelectPlan = ( planId ) => { |
| 30 | startShopCheckoutForPlan( planId, PLANS ); |
| 31 | }; |
| 32 | |
| 33 | return ( |
| 34 | <div className="flex items-center justify-center w-full h-[calc(70vh)]"> |
| 35 | <div className="text-center"> |
| 36 | <h1 className="text-3xl font-semibold m-0"> |
| 37 | { __( 'No active licenses there yet', 'advanced-ads' ) } |
| 38 | </h1> |
| 39 | <p className="m-0 mt-3 mb-8 text-gray-500 text-base"> |
| 40 | { __( |
| 41 | 'Purchase a license to unlock premium features.', |
| 42 | 'advanced-ads' |
| 43 | ) } |
| 44 | <br /> |
| 45 | { __( |
| 46 | 'Free plugins don’t require a license and won’t appear here.', |
| 47 | 'advanced-ads' |
| 48 | ) } |
| 49 | </p> |
| 50 | <div className="flex items-center justify-center gap-x-4"> |
| 51 | <a |
| 52 | href={ `${ advancedAds.endpoints.shopUrl }/sso-login?site=${ advancedAds.endpoints.siteUrl }&utm_source=advancedads&utm_medium=in-plugin&utm_campaign=a2-in_plugin-licenses_addons-connect-no_licenses` } |
| 53 | className="button advads-button-neutral is-big" |
| 54 | > |
| 55 | { __( 'Connect license', 'advanced-ads' ) } |
| 56 | </a> |
| 57 | |
| 58 | <button |
| 59 | type="button" |
| 60 | className="button advads-button-secondary is-big" |
| 61 | onClick={ handlePricingOpen } |
| 62 | > |
| 63 | { __( 'Buy license', 'advanced-ads' ) } |
| 64 | </button> |
| 65 | </div> |
| 66 | </div> |
| 67 | { isPricingOpen && ( |
| 68 | <PricingModal |
| 69 | onClose={ handlePricingClose } |
| 70 | currentActionLabel={ __( 'Buy plan', 'advanced-ads' ) } |
| 71 | onSelectPlan={ handleSelectPlan } |
| 72 | /> |
| 73 | ) } |
| 74 | </div> |
| 75 | ); |
| 76 | } |
| 77 |