import { __ } from '@wordpress/i18n';
import { InspectorControls } from '@wordpress/block-editor';
import { PanelBody, ToggleControl } from '@wordpress/components';

export default function Edit( { attributes, setAttributes } ) {
	const { metaDate, metaAuthor, hideIfEmpty } = attributes;

	return (
		<>
			<InspectorControls>
				<PanelBody title={ __( 'Result Meta', 'wlc-search-integration-with-algolia' ) } initialOpen={ true }>
					<ToggleControl
						label={ __( 'Show date', 'wlc-search-integration-with-algolia' ) }
						checked={ !! metaDate }
						onChange={ ( v ) => setAttributes( { metaDate: !! v } ) }
					/>
					<ToggleControl
						label={ __( 'Show author', 'wlc-search-integration-with-algolia' ) }
						checked={ !! metaAuthor }
						onChange={ ( v ) => setAttributes( { metaAuthor: !! v } ) }
					/>
					<ToggleControl
						label={ __( 'Hide if empty', 'wlc-search-integration-with-algolia' ) }
						checked={ hideIfEmpty !== false }
						onChange={ ( v ) => setAttributes( { hideIfEmpty: !! v } ) }
					/>
				</PanelBody>
			</InspectorControls>

			<div style={ { fontSize: 12, opacity: 0.75 } }>
				{ __( 'Meta: date / author', 'wlc-search-integration-with-algolia' ) }
			</div>
		</>
	);
}




