From 0bd399039b143cd538f24073383d81293e6f48dc Mon Sep 17 00:00:00 2001 From: alma Date: Wed, 16 Apr 2025 13:47:48 +0200 Subject: [PATCH] mail page ui correction maj compose 20 bis --- app/mail/page.tsx | 64 +++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/app/mail/page.tsx b/app/mail/page.tsx index c92756b..5600b63 100644 --- a/app/mail/page.tsx +++ b/app/mail/page.tsx @@ -466,28 +466,22 @@ export default function MailPage() { const [attachments, setAttachments] = useState([]); const [folders, setFolders] = useState([]); - // Update the filteredEmails logic + // Update the filteredEmails logic to match how Inbox works const filteredEmails = useMemo(() => { - return emails.filter(email => { - // First filter by account if one is selected - if (selectedAccount && selectedAccount.id !== 0) { - if (email.accountId !== selectedAccount.id) return false; - } - - // Then filter by current view - switch (currentView) { - case 'inbox': - return !email.deleted && !email.category?.includes('sent'); - case 'starred': - return !email.deleted && email.starred === true; - case 'sent': - return !email.deleted && email.category?.includes('sent'); - case 'trash': - return email.deleted === true; - default: - return false; - } - }); + if (!emails) return []; + + switch (currentView) { + case 'inbox': + return emails; // This is working, so let's use similar logic for others + case 'starred': + return emails.filter(email => email.starred); + case 'sent': + return emails.filter(email => email.from === selectedAccount?.email); + case 'trash': + return emails.filter(email => email.deleted); + default: + return emails; + } }, [emails, currentView, selectedAccount]); // Move getSelectedEmail inside the component @@ -1041,26 +1035,39 @@ export default function MailPage() { {/* Email list header */}
-
+
{emails.length > 0 && ( )} - - {filteredEmails.length} emails - +

+ {currentView} +

+
+
+ {filteredEmails.length} emails
- {/* Email list with proper spacing and layout */} + {/* Email list */}
{loading ? (
+ ) : filteredEmails.length === 0 ? ( +
+ +

+ {currentView === 'inbox' && 'No emails in inbox'} + {currentView === 'starred' && 'No starred emails'} + {currentView === 'sent' && 'No sent emails'} + {currentView === 'trash' && 'No emails in trash'} +

+
) : (
{filteredEmails.map((email) => ( @@ -1071,7 +1078,6 @@ export default function MailPage() { } ${!email.read ? 'bg-blue-50/20' : ''}`} onClick={() => handleEmailSelect(email.id)} > - {/* Email header with checkbox and date */}
- {email.fromName || email.from} + {currentView === 'sent' ? email.to : (email.fromName || email.from)}
@@ -1103,8 +1109,6 @@ export default function MailPage() {
- - {/* Email subject and preview */}

{email.subject}