/** * WordPress dependencies */ import { Dashicon } from '@safe-wordpress/components'; import { useSelect } from '@safe-wordpress/data'; import { _x } from '@safe-wordpress/i18n'; /** * External dependencies */ import { find } from 'lodash'; import { store as NAB_ACTIONS } from '@nab/conversion-actions'; import { store as NAB_DATA } from '@nab/data'; import type { ConversionAction as CA, ConversionActionTypeName, } from '@nab/types'; /** * Internal dependencies */ import './style.scss'; export type ConversionActionProps = { readonly action: CA; }; export const ConversionAction = ( { action, }: ConversionActionProps ): JSX.Element | null => { const experiment = useActiveExperiment(); const goalId = useActiveGoalId(); const actionType = useConversionActionType( action.type ); const goal = find( experiment?.goals, { id: goalId } ); if ( ! actionType || ! experiment || ! goalId || ! goal ) { return null; } const attributes = { ...actionType.attributes, ...action.attributes, }; const View = actionType.view; const Icon = actionType.icon; const goalIndex = experiment.goals.map( ( g ) => g.id ).indexOf( goalId ); return (