import * as React from 'react';

import { BlockSaveProps } from '@wordpress/blocks';

import { EmbedMode, IBlockAttributes } from './types';

const Save: React.FC<BlockSaveProps<IBlockAttributes>> = ( { attributes: { formId, embedMode, seamlessEmbedCode, iframeEmbedCode } } ) => {
	let embedCode = '';

	switch ( embedMode ) {
		case EmbedMode.Seamless:
			embedCode = seamlessEmbedCode;
			break;
		case EmbedMode.IFrame:
			embedCode = iframeEmbedCode;
			break;
	}

	return (
		<div
			className="cog-wp-embed"
			data-form={ formId }
			dangerouslySetInnerHTML={ { __html: embedCode } }
		>
		</div>
	);
};

export default Save;
