/** * External dependencies */ import { getNewPath } from '@woocommerce/navigation'; 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 RefreshIcon from '../../assets/images/refresh.svg'; export default function MySubscriptions(): JSX.Element { const { subscriptions, isLoading } = useContext( SubscriptionsContext ); const wccomSettings = getAdminSetting( 'wccomHelper', {} ); const updateConnectionUrl = getNewPath( { page: 'wc-addons', section: 'helper', filter: 'all', 'wc-helper-refresh': 1, 'wc-helper-nonce': getAdminSetting( 'wc_helper_nonces' ).refresh, 'redirect-to-wc-admin': 1, }, '' ); const installedTableDescription = createInterpolateElement( __( 'Woo.com extensions and themes installed on this store. To see all your subscriptions go to your account on Woo.com.', 'woocommerce' ), { a: ( your account ), custom_icon: , } ); const subscriptionsInstalled: Array< Subscription > = subscriptions.filter( ( subscription: Subscription ) => subscription.local.installed ); const subscriptionsAvailable: Array< Subscription > = subscriptions.filter( ( subscription: Subscription ) => ! subscriptionsInstalled.includes( subscription ) ); if ( ! wccomSettings?.isConnected ) { return (

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

{ __( 'Connect your account to get updates, manage your subscriptions, and get seamless support. Once connected, your Woo.com subscriptions will appear here.', 'woocommerce' ) }

); } return (

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

{ installedTableDescription }
{ return installedSubscriptionRow( item ); } ) } />

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

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

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