@@ -755,13 +803,13 @@ export default function MailPage() {
0 && selectedEmails.length === emails.length}
+ checked={filteredEmails.length > 0 && selectedEmails.length === filteredEmails.length}
onCheckedChange={toggleSelectAll}
className="mt-0.5"
/>
Inbox
- {emails.length} emails
+ {searchQuery ? `${filteredEmails.length} of ${emails.length} emails` : `${emails.length} emails`}
@@ -822,32 +870,146 @@ export default function MailPage() {
};
// Update the email list to include the toolbar right after the header
- const renderEmailList = () => (
-
- {renderEmailListHeader()}
- {renderBulkActionsToolbar()}
-
-
- {loading ? (
-
- ) : emails.length === 0 ? (
-
-
-
No emails in this folder
-
- ) : (
-
- {emails.map((email) => renderEmailListItem(email))}
- {isLoadingMore && (
-
-
+ const renderEmailListWrapper = () => (
+
+ {/* Email list panel */}
+ {renderEmailList()}
+
+ {/* Preview panel - will automatically take remaining space */}
+
+ {selectedEmail ? (
+ <>
+ {/* Email actions header */}
+
+
+
+ setSelectedEmail(null)}
+ className="md:hidden"
+ >
+
+
+
+ {selectedEmail.subject}
+
+
+
+ handleReply('reply')}
+ >
+
+
+ handleReply('replyAll')}
+ >
+
+
+ handleReply('forward')}
+ >
+
+
+ toggleStarred(selectedEmail.id, e)}
+ >
+
+
+ {/* Add to folder logic */}}
+ >
+
+
+ {/* Mark as spam logic */}}
+ >
+
+
+
- )}
+
+
+ {/* Scrollable content area */}
+
+
+
+
+ {selectedEmail.fromName?.charAt(0) || selectedEmail.from.charAt(0)}
+
+
+
+
+ {selectedEmail.fromName || selectedEmail.from}
+
+
+ to {selectedEmail.to}
+
+
+
+ {formatDate(selectedEmail.date)}
+
+
+
+
+ {(() => {
+ try {
+ const parsed = parseFullEmail(selectedEmail.body);
+ return (
+
+ {/* Display HTML content if available, otherwise fallback to text */}
+
+
+ {/* Display attachments if present */}
+ {parsed.attachments && parsed.attachments.length > 0 && (
+
+
Attachments
+
+ {parsed.attachments.map((attachment, index) => (
+
+
+
+ {attachment.filename}
+
+
+ ))}
+
+
+ )}
+
+ );
+ } catch (e) {
+ console.error('Error parsing email:', e);
+ return selectedEmail.body;
+ }
+ })()}
+
+
+ >
+ ) : (
+
+
+
Select an email to view its contents
)}