import * as React from 'react';

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

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

const Save: React.FC<BlockSaveProps<BlockAttributes>> = ( { 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;
