/** * WordPress dependencies */ import { _x, sprintf } from '@safe-wordpress/i18n'; /** * External dependencies */ import { find, trim } from 'lodash'; import { SegmentationRule } from '@nab/components'; import { usePageAttribute } from '@nab/data'; /** * Internal dependencies */ import { useExperimentAttribute } from '../hooks'; export const SegmentationRuleList = (): JSX.Element | null => { const status = useExperimentAttribute( 'status' ); const segmentationRules = useSegmentationRules(); const [ activeSegmentId ] = usePageAttribute( 'editor/activeSegment', 'default' ); const segments = useExperimentAttribute( 'segments' ) || []; const isDefaultSegment = 'default' === activeSegmentId && 1 < segments.length; if ( ! segmentationRules.length && ! isDefaultSegment ) { return null; } if ( isDefaultSegment ) { return ( <>
{ _x( 'Results from visitors that belong to any segment.', 'text', 'nelio-ab-testing' ) }
) : ({ _x( 'Results from visitors that belonged to any segment.', 'text', 'nelio-ab-testing' ) }
) } > ); } const segment = segments.find( ( s ) => s.id === activeSegmentId ); if ( ! segment ) { return null; } const segmentIndex = segments.findIndex( ( s ) => s.id === activeSegmentId ); return ( <>{ _x( 'Results from visitors that match all of the following segmentation rules:', 'text', 'nelio-ab-testing' ) }
) : ({ _x( 'Results from visitors that matched all of the following segmentation rules:', 'text', 'nelio-ab-testing' ) }
) }