/** * External dependencies */ import { Button } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; import { createInterpolateElement, useContext } from '@wordpress/element'; import { Icon, external } from '@wordpress/icons'; /** * Internal dependencies */ import { getAdminSetting } from '../../../utils/admin-settings'; import { SubscriptionsContext } from '../../contexts/subscriptions-context'; import './my-subscriptions.scss'; import { AvailableSubscriptionsTable, InstalledSubscriptionsTable, } from './table/table'; import { availableSubscriptionRow, installedSubscriptionRow, } from './table/table-rows'; import { Subscription } from './types'; import { RefreshButton } from './table/actions/refresh-button'; import Notices from './notices'; import InstallModal from './table/actions/install-modal'; import { connectUrl } from '../../utils/functions'; import PluginInstallNotice from '../woo-update-manager-plugin/plugin-install-notice'; export default function MySubscriptions(): JSX.Element { const { subscriptions, isLoading } = useContext( SubscriptionsContext ); const wccomSettings = getAdminSetting( 'wccomHelper', {} ); const installedTableDescription = createInterpolateElement( __( 'WooCommerce.com extensions and themes installed on this store. To see all your subscriptions go to your account on WooCommerce.com.', 'woocommerce' ), { a: ( your account ), custom_icon: , } ); const subscriptionsInstalled: Array< Subscription > = subscriptions.filter( ( subscription: Subscription ) => subscription.subscription_installed ); const subscriptionsAvailable: Array< Subscription > = subscriptions.filter( ( subscription: Subscription ) => ! subscription.subscription_installed && wccomSettings?.wooUpdateManagerPluginSlug !== subscription.product_slug ); if ( ! wccomSettings?.isConnected ) { const connectMessage = __( "Connect your store to WooCommerce.com using the WooCommerce.com Update Manager. Once connected, you'll be able to manage your subscriptions, receive product updates, and access streamlined support from this screen.", 'woocommerce' ); return (

{ __( 'Manage your subscriptions', 'woocommerce' ) }

{ connectMessage }

); } return (

{ __( 'Installed on this store', 'woocommerce' ) }

{ installedTableDescription }

{ return installedSubscriptionRow( item ); } ) } />
{ subscriptionsAvailable.length > 0 && (

{ __( 'Available to use', 'woocommerce' ) }

{ __( "WooCommerce.com subscriptions you haven't used yet.", 'woocommerce' ) }

{ return availableSubscriptionRow( item ); } ) } />
) }
); }