panel 2 courier api
This commit is contained in:
parent
fda0e6955d
commit
7269d4a07d
@ -101,36 +101,65 @@ function splitEmailHeadersAndBody(emailBody: string): { headers: string; body: s
|
|||||||
}
|
}
|
||||||
|
|
||||||
function EmailContent({ email }: { email: Email }) {
|
function EmailContent({ email }: { email: Email }) {
|
||||||
|
// Add debugging logs
|
||||||
|
console.log("EmailContent rendering with:", {
|
||||||
|
hasContent: Boolean(email.content),
|
||||||
|
contentLength: email.content?.length || 0,
|
||||||
|
hasTextContent: Boolean(email.textContent),
|
||||||
|
textContentLength: email.textContent?.length || 0,
|
||||||
|
hasRawContent: Boolean(email.rawContent),
|
||||||
|
rawContentLength: email.rawContent?.length || 0,
|
||||||
|
hasBody: Boolean(email.body),
|
||||||
|
bodyLength: email.body?.length || 0
|
||||||
|
});
|
||||||
|
|
||||||
// Use state to track if we've rendered content
|
// Use state to track if we've rendered content
|
||||||
const [renderedContent, setRenderedContent] = useState<boolean>(false);
|
const [renderedContent, setRenderedContent] = useState<boolean>(false);
|
||||||
|
|
||||||
|
// Use a more defensive approach with content
|
||||||
|
const hasContent = email.content !== undefined && email.content !== null && email.content.trim() !== '';
|
||||||
|
const hasTextContent = email.textContent !== undefined && email.textContent !== null && email.textContent.trim() !== '';
|
||||||
|
const hasRawContent = email.rawContent !== undefined && email.rawContent !== null && email.rawContent.trim() !== '';
|
||||||
|
const hasBody = email.body !== undefined && email.body !== null && email.body.trim() !== '';
|
||||||
|
|
||||||
// If textContent is available, render it directly
|
// If textContent is available, render it directly
|
||||||
if (email.textContent && !renderedContent) {
|
if (hasTextContent && !renderedContent) {
|
||||||
setRenderedContent(true);
|
setRenderedContent(true);
|
||||||
return (
|
return (
|
||||||
<div className="email-content whitespace-pre-wrap">
|
<div className="email-content whitespace-pre-wrap">
|
||||||
{email.textContent}
|
{email.textContent || ''}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If html content is available, render it directly
|
// If html content is available, render it directly
|
||||||
if (email.content && !renderedContent) {
|
if (hasContent && !renderedContent) {
|
||||||
setRenderedContent(true);
|
setRenderedContent(true);
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="email-content prose prose-sm max-w-none dark:prose-invert"
|
className="email-content prose prose-sm max-w-none dark:prose-invert"
|
||||||
dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(email.content) }}
|
dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(email.content || '') }}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try body field (backward compatibility)
|
||||||
|
if (hasBody && !renderedContent) {
|
||||||
|
setRenderedContent(true);
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className="email-content prose prose-sm max-w-none dark:prose-invert"
|
||||||
|
dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(email.body || '') }}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback to raw content if available
|
// Fallback to raw content if available
|
||||||
if (email.rawContent && !renderedContent) {
|
if (hasRawContent && !renderedContent) {
|
||||||
setRenderedContent(true);
|
setRenderedContent(true);
|
||||||
return (
|
return (
|
||||||
<div className="email-content whitespace-pre-wrap text-sm bg-gray-50 p-3 rounded">
|
<div className="email-content whitespace-pre-wrap text-sm bg-gray-50 p-3 rounded">
|
||||||
{email.rawContent}
|
{email.rawContent || ''}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user