From b91c218c48cd95cee7607d8125762f6b7eb28a4f Mon Sep 17 00:00:00 2001 From: alma Date: Wed, 16 Apr 2025 19:24:51 +0200 Subject: [PATCH] Neah version mail design fix 9 --- app/mail/page.tsx | 218 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 190 insertions(+), 28 deletions(-) diff --git a/app/mail/page.tsx b/app/mail/page.tsx index cfc2176..2a07524 100644 --- a/app/mail/page.tsx +++ b/app/mail/page.tsx @@ -737,7 +737,55 @@ export default function MailPage() { } }; - // Update the email list header to include search and adjust spacing + // Add filtered emails based on search query + const filteredEmails = useMemo(() => { + if (!searchQuery) return emails; + + const query = searchQuery.toLowerCase(); + return emails.filter(email => + email.subject.toLowerCase().includes(query) || + email.from.toLowerCase().includes(query) || + email.to.toLowerCase().includes(query) || + email.body.toLowerCase().includes(query) + ); + }, [emails, searchQuery]); + + // Update the email list to use filtered emails + const renderEmailList = () => ( +
+ {renderEmailListHeader()} + {renderBulkActionsToolbar()} + +
+ {loading ? ( +
+
+
+ ) : filteredEmails.length === 0 ? ( +
+ +

+ {searchQuery ? 'No emails match your search' : 'No emails in this folder'} +

+
+ ) : ( +
+ {filteredEmails.map((email) => renderEmailListItem(email))} + {isLoadingMore && ( +
+
+
+ )} +
+ )} +
+
+ ); + + // Update the email count in the header to show filtered count const renderEmailListHeader = () => (
@@ -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 */} +
+
+
+ +

+ {selectedEmail.subject} +

+
+
+ + + + + + +
- )} +
+ + {/* 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

)}