diff --git a/app/courrier/page.tsx b/app/courrier/page.tsx index 6b216e3d..360e79fc 100644 --- a/app/courrier/page.tsx +++ b/app/courrier/page.tsx @@ -546,6 +546,25 @@ export default function CourrierPage() { throw new Error(errorData.error || 'Failed to check credentials'); } + try { + // Try to get user email from credentials + const credsData = await credResponse.json(); + if (credsData.email) { + console.log('Got email from credentials:', credsData.email); + setAccounts(prev => prev.map(account => + account.id === 1 + ? { + ...account, + name: credsData.email, + email: credsData.email + } + : account + )); + } + } catch (error) { + console.warn('Error getting email from credentials:', error); + } + // First do a quick request just for folders try { const folderResponse = await fetch('/api/courrier?folder=INBOX&page=1&limit=1'); @@ -648,12 +667,16 @@ export default function CourrierPage() { loadInitialData(); }, [router, currentView, page, emailsPerPage]); - // At the initialization, update the account with the email from session + // Fix the type issue with the session email useEffect(() => { if (session?.user?.email) { setAccounts(prev => prev.map(account => account.id === 1 - ? { ...account, name: session.user.email, email: session.user.email } + ? { + ...account, + name: session.user.email || 'Mail Account', + email: session.user.email || '' + } : account )); }