diff --git a/DEPRECATED_FUNCTIONS.md b/DEPRECATED_FUNCTIONS.md index d54073b2..f389c850 100644 --- a/DEPRECATED_FUNCTIONS.md +++ b/DEPRECATED_FUNCTIONS.md @@ -80,4 +80,17 @@ A compatibility layer has been added to the new component to ensure backward com ### Phase 2: Removal (Future) - Remove deprecated functions after ensuring no code uses them - Ensure proper migration path for any code that might have been using these functions -- Update documentation to remove references to deprecated code \ No newline at end of file +- Update documentation to remove references to deprecated code + +## Server-Client Code Separation + +### Server-side imports in client components +- **Status**: Fixed in November 2023 +- **Issue**: Server-only modules like ImapFlow were being imported directly in client components, causing build errors with messages like "Module not found: Can't resolve 'tls'" +- **Fix**: + 1. Added 'use server' directive to server-only modules + 2. Created client-safe interfaces in client components + 3. Added server actions for email operations that need server capabilities + 4. Refactored ComposeEmail component to avoid direct server imports + +This architecture ensures a clean separation between server and client code, which is essential for Next.js applications, particularly with the App Router. It prevents Node.js-specific modules from being bundled into client-side JavaScript. \ No newline at end of file diff --git a/app/courrier/page.tsx b/app/courrier/page.tsx index 08535309..9e84e056 100644 --- a/app/courrier/page.tsx +++ b/app/courrier/page.tsx @@ -1616,93 +1616,47 @@ export default function CourrierPage() { // New helper function to directly format email content const formatEmailAndShowCompose = (email: Email, type: 'reply' | 'reply-all' | 'forward') => { - try { - console.log('[DEBUG] Formatting email for', type); - - // Get email sender name and address - const senderName = email.fromName || email.from.split('@')[0]; - const senderEmail = email.from; - - // Format date properly - const formattedDate = formatDate(new Date(email.date)); - - // Set flag for component rendering - if (type === 'forward') { - setIsForwarding(true); - } else { - setIsReplying(true); - } - - // Set recipients based on reply type - if (type === 'reply') { - setComposeTo(senderName ? `${senderName} <${senderEmail}>` : senderEmail); - } else if (type === 'reply-all') { - // To: original sender - setComposeTo(senderName ? `${senderName} <${senderEmail}>` : senderEmail); - - // CC: all other recipients (simplified) - if (email.cc) { - setComposeCc(email.cc); - setShowCc(true); - } - } - - // Format subject - let subject = email.subject || 'No Subject'; - // Remove existing prefixes to avoid duplication - subject = subject.replace(/^(Re|Fwd):\s*/gi, ''); - - // Add appropriate prefix - if (type === 'forward') { - subject = `Fwd: ${subject}`; - } else { - subject = `Re: ${subject}`; - } - setComposeSubject(subject); - - // Format content - let formattedContent = ''; - - if (type === 'forward') { - formattedContent = ` -
----On ${formattedDate}, ${senderName} <${senderEmail}> wrote:-${email.html || email.content || 'No content available'}-