panel 2 courier api
This commit is contained in:
parent
7269d4a07d
commit
f573d79960
@ -101,8 +101,9 @@ function splitEmailHeadersAndBody(emailBody: string): { headers: string; body: s
|
|||||||
}
|
}
|
||||||
|
|
||||||
function EmailContent({ email }: { email: Email }) {
|
function EmailContent({ email }: { email: Email }) {
|
||||||
// Add debugging logs
|
// Improved debugging with more details
|
||||||
console.log("EmailContent rendering with:", {
|
console.log("EmailContent rendering with EMAIL OBJECT:", email);
|
||||||
|
console.log("Content details:", {
|
||||||
hasContent: Boolean(email.content),
|
hasContent: Boolean(email.content),
|
||||||
contentLength: email.content?.length || 0,
|
contentLength: email.content?.length || 0,
|
||||||
hasTextContent: Boolean(email.textContent),
|
hasTextContent: Boolean(email.textContent),
|
||||||
@ -164,8 +165,19 @@ function EmailContent({ email }: { email: Email }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Last resort
|
// Last resort - show a better error message with debugging info
|
||||||
return <div className="text-gray-500">No content available</div>;
|
return (
|
||||||
|
<div className="text-gray-500">
|
||||||
|
<p>No content available</p>
|
||||||
|
<div className="mt-2 p-2 bg-red-50 text-red-700 text-xs rounded">
|
||||||
|
<p>Content flags:</p>
|
||||||
|
<p>- Has content: {hasContent ? 'Yes' : 'No'}</p>
|
||||||
|
<p>- Has text content: {hasTextContent ? 'Yes' : 'No'}</p>
|
||||||
|
<p>- Has raw content: {hasRawContent ? 'Yes' : 'No'}</p>
|
||||||
|
<p>- Has body: {hasBody ? 'Yes' : 'No'}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderEmailContent(email: Email) {
|
function renderEmailContent(email: Email) {
|
||||||
@ -629,17 +641,27 @@ export default function CourrierPage() {
|
|||||||
const fullEmail = await response.json();
|
const fullEmail = await response.json();
|
||||||
console.log("API RESPONSE for email:", JSON.stringify(fullEmail, null, 2));
|
console.log("API RESPONSE for email:", JSON.stringify(fullEmail, null, 2));
|
||||||
|
|
||||||
// Create a safe version of the email with guaranteed fields
|
// Create a clean, processed version of the email ensuring all necessary fields exist
|
||||||
const safeEmail = {
|
const processedEmail = {
|
||||||
...fullEmail,
|
...fullEmail,
|
||||||
content: fullEmail.content || "",
|
id: fullEmail.id || emailId,
|
||||||
textContent: fullEmail.textContent || "",
|
content: typeof fullEmail.content === 'string' ? fullEmail.content : '',
|
||||||
rawContent: fullEmail.rawContent || "",
|
textContent: typeof fullEmail.textContent === 'string' ? fullEmail.textContent : '',
|
||||||
body: fullEmail.body || ""
|
rawContent: typeof fullEmail.rawContent === 'string' ? fullEmail.rawContent : '',
|
||||||
|
body: typeof fullEmail.body === 'string' ? fullEmail.body : '',
|
||||||
|
from: fullEmail.from || initialEmail?.from || '',
|
||||||
|
fromName: fullEmail.fromName || initialEmail?.fromName || '',
|
||||||
|
to: fullEmail.to || initialEmail?.to || '',
|
||||||
|
subject: fullEmail.subject || initialEmail?.subject || '(No subject)',
|
||||||
|
date: fullEmail.date || initialEmail?.date || new Date().toISOString(),
|
||||||
|
read: fullEmail.read !== undefined ? fullEmail.read : true,
|
||||||
|
folder: fullEmail.folder || currentView
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log("Processed email for UI:", processedEmail);
|
||||||
|
|
||||||
// Set the selected email with complete information
|
// Set the selected email with complete information
|
||||||
setSelectedEmail(safeEmail);
|
setSelectedEmail(processedEmail);
|
||||||
|
|
||||||
// Update the email in the list to mark it as read
|
// Update the email in the list to mark it as read
|
||||||
setEmails((prevEmails) =>
|
setEmails((prevEmails) =>
|
||||||
@ -1036,9 +1058,16 @@ export default function CourrierPage() {
|
|||||||
<div className="flex justify-between items-center mb-2">
|
<div className="flex justify-between items-center mb-2">
|
||||||
<h4 className="text-xs font-medium text-blue-800">Direct Content Preview</h4>
|
<h4 className="text-xs font-medium text-blue-800">Direct Content Preview</h4>
|
||||||
</div>
|
</div>
|
||||||
<div className="text-xs overflow-auto max-h-20">
|
<div className="text-xs overflow-auto max-h-[300px]">
|
||||||
<strong>Content:</strong> {selectedEmail.content ? selectedEmail.content.substring(0, 200) : 'Empty'}<br/>
|
<strong>Content:</strong> {selectedEmail.content
|
||||||
<strong>Text Content:</strong> {selectedEmail.textContent ? selectedEmail.textContent.substring(0, 200) : 'Empty'}<br/>
|
? <div className="mt-1 p-1 bg-white/80 rounded overflow-auto max-h-[100px]">{selectedEmail.content.substring(0, 500)}...</div>
|
||||||
|
: 'Empty'}<br/>
|
||||||
|
<strong>Text Content:</strong> {selectedEmail.textContent
|
||||||
|
? <div className="mt-1 p-1 bg-white/80 rounded overflow-auto max-h-[100px]">{selectedEmail.textContent.substring(0, 500)}...</div>
|
||||||
|
: 'Empty'}<br/>
|
||||||
|
<strong>Raw Content:</strong> {selectedEmail.rawContent
|
||||||
|
? <div className="mt-1 p-1 bg-white/80 rounded overflow-auto max-h-[100px]">{selectedEmail.rawContent.substring(0, 500)}...</div>
|
||||||
|
: 'Empty'}<br/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user