diff --git a/app/courrier/page.tsx b/app/courrier/page.tsx index e0820d22..7a81cc10 100644 --- a/app/courrier/page.tsx +++ b/app/courrier/page.tsx @@ -112,10 +112,10 @@ export default function CourrierPage() { const [prefetchStarted, setPrefetchStarted] = useState(false); const [showFolders, setShowFolders] = useState(true); - // Mock accounts for the sidebar + // Email accounts for the sidebar const [accounts, setAccounts] = useState([ { id: 0, name: 'All', email: '', color: 'bg-gray-500' }, - { id: 1, name: 'Mail', email: 'user@example.com', color: 'bg-blue-500', folders: mailboxes } + { id: 1, name: 'Loading...', email: '', color: 'bg-blue-500', folders: mailboxes } ]); const [selectedAccount, setSelectedAccount] = useState(null); @@ -168,6 +168,20 @@ export default function CourrierPage() { console.log('Session initialized, prefetch status:', data.prefetchStarted ? 'running' : 'not started'); setPrefetchStarted(Boolean(data.prefetchStarted)); + // Update the accounts with the actual email address + if (data.email) { + setAccounts(prev => { + const updated = [...prev]; + updated[1] = { + ...updated[1], + name: data.email.split('@')[0] || 'Email', + email: data.email, + folders: mailboxes + }; + return updated; + }); + } + // Preload first page of emails for faster initial rendering if (session?.user?.id) { await loadEmails(); @@ -208,7 +222,7 @@ export default function CourrierPage() { return () => { isMounted = false; }; - }, [session?.user?.id, loadEmails, currentFolder]); + }, [session?.user?.id, loadEmails, currentFolder, mailboxes]); // Helper to get folder icons const getFolderIcon = (folder: string) => { @@ -439,9 +453,17 @@ export default function CourrierPage() { {account.name} {account.id !== 0 && ( - showFolders ? - : - +
+ {account.email && ( + + {account.email} + + )} + {showFolders ? + : + + } +
)} @@ -464,7 +486,7 @@ export default function CourrierPage() {
{React.createElement(getFolderIcon(folder), { className: "h-3.5 w-3.5" })} - {folder} + {formatFolderName(folder)}
{folder === 'INBOX' && unreadCount > 0 && (