diff --git a/app/courrier/page.tsx b/app/courrier/page.tsx index 0b47c34f..6e82f013 100644 --- a/app/courrier/page.tsx +++ b/app/courrier/page.tsx @@ -133,6 +133,9 @@ export default function CourrierPage() { // Track expanded folders for each account const [expandedAccounts, setExpandedAccounts] = useState>({}); + // Add state to track selected folder per account + const [selectedFolders, setSelectedFolders] = useState>({}); + // Update account folders when mailboxes change - update this to maintain account IDs useEffect(() => { console.log('Mailboxes updated:', mailboxes); @@ -545,7 +548,7 @@ export default function CourrierPage() { setShowComposeModal(true); }; - // Handle mailbox change with prefetching + // Update handleMailboxChange to track selected folders per account const handleMailboxChange = (folder: string, accountId?: string) => { // Reset to page 1 when changing folders setPage(1); @@ -565,6 +568,12 @@ export default function CourrierPage() { folder = 'INBOX'; } + // Update the selected folder for this account + setSelectedFolders(prev => ({ + ...prev, + [accountId]: folder + })); + // Store the current account ID with the folder change console.log(`Changing folder to ${folder} for account ${accountId}`); } @@ -582,6 +591,29 @@ export default function CourrierPage() { } }; + // Update the folder button rendering to show selected state based on account + const renderFolderButton = (folder: string, accountId: string) => { + const isSelected = selectedFolders[accountId] === folder; + return ( + + ); + }; + // Handle sending email const handleSendEmail = async (emailData: EmailData) => { return await sendEmail(emailData); @@ -951,24 +983,7 @@ export default function CourrierPage() { {/* Show folders for this account if expanded */} {expandedAccounts[account.id] && account.id !== 'all-accounts' && account.folders && (
- {account.folders.map((folder) => ( - - ))} + {account.folders.map((folder) => renderFolderButton(folder, account.id))}
)}