import { Button } from '@wordpress/components'; import { Header, Title, Action, Description } from '../Elements'; import SettingsBlock from '../SettingsBlock'; import TitleBadge from '../TitleBadge'; const FeatureSettingsBlock = ( { title, description, ...props } ) => { const printNotes = () => { const notes = props.actionProps?.notes; if ( ! notes || ( Array.isArray( notes ) && notes.length === 0 ) ) { return null; } return ( { notes.map( ( note, index ) => ( { note } ) ) } ); }; const renderButton = ( button ) => { const buttonElement = ( { button.text } ); // If there's a URL (either direct or in urls object), wrap in anchor tag if ( button.url || button.urls ) { const href = button.urls ? button.urls.live : button.url; return ( { buttonElement } ); } return buttonElement; }; return ( { title } { props.actionProps?.enabled && ( ) } { description } { printNotes() } { props.actionProps?.buttons.map( renderButton ) } ); }; export default FeatureSettingsBlock;