+
+
Error: No original message content available.
+
+ Please select the email again or try refreshing the page.
+
+
+ `;
return;
}
@@ -103,6 +122,8 @@ export default function ComposeEmail({
`;
+ console.log('[DEBUG] Sending content to parse-email API, length:', emailToProcess.content.length);
+
// Parse the original email using the API
const response = await fetch('/api/parse-email', {
method: 'POST',
@@ -112,12 +133,24 @@ export default function ComposeEmail({
body: JSON.stringify({ email: emailToProcess.content }),
});
+ console.log('[DEBUG] Parse-email API response status:', response.status);
+
const data = await response.json();
+ console.log('[DEBUG] Parse-email API response:', {
+ hasHtml: !!data.html,
+ hasText: !!data.text,
+ subject: data.subject,
+ error: data.error
+ });
+
if (!response.ok) {
throw new Error(data.error || 'Failed to parse email');
}
const emailContent = data.html || data.text || '';
+ if (!emailContent) {
+ console.warn('[DEBUG] No HTML or text content returned from parser');
+ }
// Format the reply/forward content
const quotedContent = forwardFrom ? `
@@ -167,14 +200,18 @@ export default function ComposeEmail({
// Update compose state
setComposeBody(formattedContent);
setLocalContent(formattedContent);
+ console.log('[DEBUG] Successfully set compose content');
}
} catch (error) {
- console.error('Error initializing compose content:', error);
+ console.error('[DEBUG] Error initializing compose content:', error);
if (composeBodyRef.current) {
const errorContent = `
Error loading original message.
+
+ Technical details: ${error instanceof Error ? error.message : 'Unknown error'}
+
`;
composeBodyRef.current.innerHTML = errorContent;