import Placeholder from "react-bootstrap/Placeholder";
import React from "react";
import Stack from "react-bootstrap/Stack";

import { IAccount, IEmail, IMailbox } from "./client/types";
import Client from "./client/Client";
import EmailContent from "./EmailContent";
import EmailList from "./EmailList";

type EmailContentHTMLProps = {
	email: IEmail;
};

const EmailContentHTML: React.FC<EmailContentHTMLProps> = (props) => {
	const email = props.email;
	if (email.htmlBody == null) {
		return <Placeholder />;
	}
	return (
		<Stack>
			{email.htmlBody.map((h) =>
				h.partId === undefined ? (
					<Placeholder />
				) : (
					<div
						key={h.partId}
						dangerouslySetInnerHTML={{
							__html: email.bodyValues![h.partId].value,
						}}
					/>
				),
			)}
		</Stack>
	);
};
export default EmailContentHTML;
