/**
 * External dependencies.
 */
import { SelectControl } from '@wordpress/components';
import { __ } from '@wordpress/i18n';

/**
 * Internal dependencies.
 */
import { FEATURED_IMAGE_OPTIONS } from '@spectra-pro-extensions/dynamic-content/utils/constants';

/**
 * Renders a select control for choosing a featured image attribute.
 *
 * Allows users to select a featured image attribute and updates the dynamic content
 * settings with the selected value.
 *
 * @since x.x.x
 *
 * @param {Object}   props               - The component props.
 * @param {Object}   props.settings      - The dynamic content settings from the context.
 * @param {Function} props.updateSetting - Function to update settings in the context.
 * @return {Element} The featured image attribute select control.
 */
const FeatureImageField = ( { settings, updateSetting } ) => (
	<SelectControl
		label={ __( 'Featured Image Attribute', 'spectra-pro' ) }
		value={ settings.source.featuredImageField }
		options={ FEATURED_IMAGE_OPTIONS }
		onChange={ ( newValue ) => updateSetting( 'source.featuredImageField', newValue ) }
	/>
);

export default FeatureImageField;
