From 28a2866e13f6df14f82a0f354af6a3b60dc71c12 Mon Sep 17 00:00:00 2001 From: alma Date: Thu, 15 Jan 2026 23:39:06 +0100 Subject: [PATCH] widget courrier refactor --- components/email.tsx | 46 ++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/components/email.tsx b/components/email.tsx index 9418e65..bd74282 100644 --- a/components/email.tsx +++ b/components/email.tsx @@ -34,7 +34,7 @@ export function Email() { const [refreshing, setRefreshing] = useState(false); const [error, setError] = useState(null); const [mailUrl, setMailUrl] = useState(null); - const [accounts, setAccounts] = useState>([]); + const [accounts, setAccounts] = useState>([]); const [unreadCount, setUnreadCount] = useState(0); const [accountErrors, setAccountErrors] = useState>({}); @@ -59,7 +59,8 @@ export function Email() { if (data.accounts) { setAccounts(data.accounts.map((acc: any) => ({ id: acc.id || acc.email, - email: acc.email + email: acc.email, + color: acc.color || '#0082c9' // Default color if not set }))); } } @@ -128,7 +129,7 @@ export function Email() { })) // Sort emails by date (most recent first) .sort((a: Email, b: Email) => new Date(b.date).getTime() - new Date(a.date).getTime()) - .slice(0, 5); // Only show the first 5 emails + .slice(0, 33); // Show up to 33 emails setEmails(transformedEmails); setMailUrl('/courrier'); @@ -249,24 +250,31 @@ export function Email() {

Aucun email

) : ( -
- {emails.map((email) => ( -
-
- {email.read ? - : - - } -
-
-
-

{email.fromName || email.from.split('@')[0]}

-

{formatDate(email.date)}

+
+ {emails.map((email) => { + // Find the account color for this email + const account = accounts.find(acc => acc.id === (email as any).accountId); + const accountColor = account?.color || '#0082c9'; + + return ( +
+
+
+
+
+
+

{email.fromName || email.from.split('@')[0]}

+

{formatDate(email.date)}

+
+

{email.subject}

-

{email.subject}

-
- ))} + ); + })} {mailUrl && (