/**
 * React hook that is used to mark the block wrapper element.
 * It provides all the necessary props like the class name.
 *
 * @see https://developer.wordpress.org/block-editor/reference-guides/packages/packages-block-editor/#useblockprops
 */
import { useBlockProps, InnerBlocks, RichText } from '@wordpress/block-editor';
import { SelectControl } from '@wordpress/components';

/**
 * The save function defines the way in which the different attributes should
 * be combined into the final markup, which is then serialized by the block
 * editor into `post_content`. Test
 *
 * @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-edit-save/#save
 *
 * @return {WPElement} Element to render.
 */
export default function save( { attributes } ){
	const { psdmId, psdmType, psdmButtonId } = attributes;
	let psdmParameters = '';
	switch ( psdmType ) {
		case 'button':
			psdmParameters = 'id=' + psdmId + ' type=button' + ' button=' + psdmButtonId;
			break;
		case 'inline':
			psdmParameters = 'id=' + psdmId + ' type=inline';
			break;
		case 'popup':
			psdmParameters = 'id=' + psdmId + ' type=popup';
			break;
		default:
			psdmParameters = ' id=' + psdmId;
	}

	return (
		<div { ...useBlockProps.save() }>
			[downloadmagnet {psdmParameters}]
		</div>
	);
}
