import Button from "react-bootstrap/Button"; import Container from "react-bootstrap/Container"; import Placeholder from "react-bootstrap/Placeholder"; import React from "react"; import Row from "react-bootstrap/Row"; import Client from "./client/Client"; import EmailContentHTML from "./EmailContentHTML"; import EmailContentText from "./EmailContentText"; import { IAccount, IEmail } from "./client/types"; type EmailContentProps = { account: IAccount | null; client: Client | null; email: IEmail | null; emailId: string; }; type EmailContentState = { showHTML: boolean; }; class EmailContent extends React.Component< EmailContentProps, EmailContentState > { state = { showHTML: false, }; componentDidMount() { this.ensureData(); } componentDidUpdate() { this.ensureData(); } ensureData() { if (this.props.account == null) return; if (this.props.client == null) return; this.props.client.ensureEmailContent( this.props.account.id, this.props.emailId, ); } render() { const email = this.props.email; if (email == null || email.bodyValues == null) { return ; } let content; if (this.state.showHTML) { if (email.htmlBody != null) { content = ; } else { return

No HTML content

; } } else { if (email.textBody != null) { content = ; } else { return

No text content/

; } } return ( {content} ); } switchDisplay() { if (this.state.showHTML) { this.setState({ showHTML: false, }); } else { this.setState({ showHTML: true, }); } } } export default EmailContent;