diff --git a/app/courrier/page.tsx b/app/courrier/page.tsx index a2ffe4b7..2b64fbfa 100644 --- a/app/courrier/page.tsx +++ b/app/courrier/page.tsx @@ -383,6 +383,12 @@ export default function CourrierPage() { // Add all accounts from the API response data.allAccounts.forEach((account: any) => { + console.log('[DEBUG] Processing account:', { + id: account.id, + email: account.email, + folders: account.folders + }); + const accountFolders = (account.folders && Array.isArray(account.folders)) ? account.folders : ['INBOX', 'Sent', 'Drafts', 'Trash', 'Junk']; @@ -394,7 +400,11 @@ export default function CourrierPage() { color: account.color || 'bg-blue-500', folders: accountFolders }); - console.log(`[DEBUG] Added account: ${account.email} with ID ${account.id}`); + console.log(`[DEBUG] Added account with folders:`, { + id: account.id, + email: account.email, + folders: accountFolders + }); }); } else { // Fallback to single account if allAccounts is not available @@ -1021,11 +1031,22 @@ export default function CourrierPage() { {/* Show folders for this account if expanded */} - {expandedAccounts[account.id] && account.id !== 'all-accounts' && account.folders && ( -
- {account.folders.map((folder) => renderFolderButton(folder, account.id))} -
- )} + {(() => { + const isExpanded = expandedAccounts[account.id]; + const hasFolders = account.folders && account.folders.length > 0; + console.log('[DEBUG] Folder rendering check:', { + accountId: account.id, + isExpanded, + hasFolders, + folders: account.folders + }); + + return isExpanded && account.id !== 'all-accounts' && hasFolders && ( +
+ {account.folders.map((folder) => renderFolderButton(folder, account.id))} +
+ ); + })()} ))}