panel 2 courier api
This commit is contained in:
parent
93875b881f
commit
dacd083bd8
@ -248,6 +248,15 @@ function EmailContent({ email }: { email: Email }) {
|
||||
function renderEmailContent(email: Email) {
|
||||
if (!email) return <div className="text-gray-500">No email selected</div>;
|
||||
|
||||
console.log('Rendering email content:', {
|
||||
id: email.id,
|
||||
hasContent: !!email.content,
|
||||
contentStartsWith: email.content?.substring(0, 30),
|
||||
hasHtml: email.content?.includes('<html') || email.content?.includes('<body'),
|
||||
hasTextContent: !!email.textContent,
|
||||
hasRawContent: !!email.rawContent
|
||||
});
|
||||
|
||||
// Some emails might have content directly in HTML format
|
||||
if (email.content && (email.content.includes('<html') || email.content.includes('<body'))) {
|
||||
return (
|
||||
@ -721,7 +730,7 @@ export default function CourrierPage() {
|
||||
|
||||
// Then fetch the full content
|
||||
console.log(`Fetching email content for ID: ${emailId}`);
|
||||
const response = await fetch(`/api/courrier/${emailId}`);
|
||||
const response = await fetch(`/api/courrier/${emailId}?folder=${currentView}`);
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
@ -749,7 +758,7 @@ export default function CourrierPage() {
|
||||
|
||||
// Try to mark as read in the background
|
||||
try {
|
||||
const markReadResponse = await fetch(`/api/mail/mark-read`, {
|
||||
const markReadResponse = await fetch(`/api/mail/mark-read?folder=${currentView}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@ -1133,8 +1142,50 @@ export default function CourrierPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Debug info */}
|
||||
<div className="mb-4 p-3 bg-yellow-50 text-xs border border-yellow-200 rounded">
|
||||
<strong>Debug info:</strong>
|
||||
<pre className="mt-1 overflow-auto">
|
||||
{JSON.stringify({
|
||||
id: selectedEmail.id,
|
||||
hasContent: !!selectedEmail.content,
|
||||
contentLen: selectedEmail.content?.length || 0,
|
||||
hasTextContent: !!selectedEmail.textContent,
|
||||
textContentLen: selectedEmail.textContent?.length || 0,
|
||||
hasRawContent: !!selectedEmail.rawContent,
|
||||
rawContentLen: selectedEmail.rawContent?.length || 0,
|
||||
}, null, 2)}
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<div className="prose max-w-none">
|
||||
{renderEmailContent(selectedEmail)}
|
||||
{/* Server-parsed HTML content */}
|
||||
{selectedEmail.content && (
|
||||
<div className="mt-2">
|
||||
<div
|
||||
className="email-content prose prose-sm max-w-none dark:prose-invert"
|
||||
dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(selectedEmail.content) }}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Direct output fallback */}
|
||||
{!selectedEmail.content && selectedEmail.textContent && (
|
||||
<div className="mt-6 p-4 border border-blue-200 rounded bg-blue-50">
|
||||
<h3 className="text-sm font-medium mb-2">Direct Text Content:</h3>
|
||||
<div className="whitespace-pre-wrap text-sm">{selectedEmail.textContent}</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{selectedEmail.rawContent && !(selectedEmail.content || selectedEmail.textContent) && (
|
||||
<div className="mt-6 p-4 border border-red-200 rounded bg-red-50">
|
||||
<h3 className="text-sm font-medium mb-2">Raw Email Content:</h3>
|
||||
<div className="whitespace-pre-wrap text-xs max-h-96 overflow-auto">
|
||||
{selectedEmail.rawContent.substring(0, 2000)}
|
||||
{selectedEmail.rawContent.length > 2000 && '... (truncated)'}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</ScrollArea>
|
||||
</>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user