/** * WordPress dependencies */ import { useSelect } from '@safe-wordpress/data'; import { _x } from '@safe-wordpress/i18n'; /** * External dependencies */ import { EMPTY_ARRAY } from '@nab/utils'; import type { ConversionAction as CA, GoalId } from '@nab/types'; /** * Internal dependencies */ import './style.scss'; import { ConversionAction } from '../conversion-action'; import { store as NAB_EDITOR } from '../../../store'; export const AutomaticConversionActionList = (): JSX.Element => { const goalId = useActiveGoalId(); const conversionActions = useConversionActions( goalId ); return (
{ 1 === conversionActions.length ? (

{ _x( 'By default, there will be a new conversion in this test when the following conversion action occurs after the visitor has seen the tested element:', 'text', 'nelio-ab-testing' ) }

) : (

{ _x( 'Split tests are usually run with some specific goals in mind. In this type of test, there’s a new conversion when at least one of the following conversion actions occurs after the visitor has seen the tested element:', 'text', 'nelio-ab-testing' ) }

) } { goalId && conversionActions.map( ( action ) => ( ) ) }
); }; // ===== // HOOKS // ===== const useActiveGoalId = () => useSelect( ( select ) => select( NAB_EDITOR ).getActiveGoal()?.id, [] ); const useConversionActions = ( goalId?: GoalId ): ReadonlyArray< CA > => useSelect( ( select ) => { if ( ! goalId ) { return EMPTY_ARRAY; } const { getConversionActions } = select( NAB_EDITOR ); return getConversionActions( goalId ) || EMPTY_ARRAY; }, [ goalId ] );