File size: 1,747 Bytes
1e92f2d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | import { mail } from '@automattic/components/src/icons';
import { localizeUrl } from '@automattic/i18n-utils';
import { useTranslate } from 'i18n-calypso';
import React from 'react';
import { useSelector } from 'react-redux';
import useSupportDocData from 'calypso/components/inline-support-link/use-support-doc-data';
import EmptyStateAction from 'calypso/my-sites/stats/components/empty-state-action';
import {
JETPACK_SUPPORT_NEWSLETTER_URL,
NEWSLETTER_SUPPORT_URL,
} from 'calypso/my-sites/stats/const';
import { isJetpackSite } from 'calypso/state/sites/selectors';
import { getSelectedSiteId } from 'calypso/state/ui/selectors';
import type { StatsEmptyActionProps } from './';
const StatsEmptyActionEmail: React.FC< StatsEmptyActionProps > = ( { from } ) => {
const translate = useTranslate();
const siteId = useSelector( getSelectedSiteId );
const isJetpack = useSelector( ( state ) =>
isJetpackSite( state, siteId, { treatAtomicAsJetpackSite: false } )
);
const supportLink = localizeUrl(
isJetpack ? JETPACK_SUPPORT_NEWSLETTER_URL : NEWSLETTER_SUPPORT_URL
);
const { openSupportDoc } = useSupportDocData( {
supportLink,
} );
return (
<EmptyStateAction
icon={ mail }
text={ translate( 'Send emails with Newsletter' ) }
analyticsDetails={ {
from: from,
feature: 'newsletter',
} }
onClick={ () => {
// analytics event tracting handled in EmptyStateAction component
// If the site is a Jetpack site, use the Jetpack links.
// Otherwise, use the WordPress.com links.
if ( isJetpack ) {
// open in new tab
setTimeout( () => window.open( supportLink, '_blank' ), 250 );
} else {
openSupportDoc();
}
} }
/>
);
};
export default StatsEmptyActionEmail;
|