/** * WordPress dependencies */ import { createInterpolateElement } from '@safe-wordpress/element'; import { sprintf, _x } from '@safe-wordpress/i18n'; /** * External dependencies */ import { usePluginSetting } from '@nab/data'; import type { ConversionActionScope } from '@nab/types'; /** * Internal dependencies */ import './style.scss'; export type ConversionActionScopeViewProps = { readonly scope: ConversionActionScope; }; export const ConversionActionScopeView = ( { scope, }: ConversionActionScopeViewProps ): JSX.Element | null => { const goalTracking = usePluginSetting( 'goalTracking' ); if ( 'custom' !== goalTracking ) { return null; } switch ( scope.type ) { case 'all-pages': case 'test-scope': case 'php-function': return null; case 'post-ids': return (
{ createInterpolateElement( sprintf( /* translators: %s: List of page/post IDs. */ _x( 'IDs: %s', 'text', 'nelio-ab-testing' ), scope.ids .map( ( id ) => `${ id }` ) .join( ', ' ) ), { code: } ) }
); case 'urls': return (
{ createInterpolateElement( sprintf( /* translators: %s: List of URLs. */ _x( 'URLs: %s', 'text', 'nelio-ab-testing' ), scope.regexes .map( ( re ) => `${ re }` ) .join( ', ' ) ), { code: } ) }
); } };