diff --git a/components/email/EmailSidebar.tsx b/components/email/EmailSidebar.tsx index 028a194b..45913c35 100644 --- a/components/email/EmailSidebar.tsx +++ b/components/email/EmailSidebar.tsx @@ -13,8 +13,13 @@ import { Badge } from '@/components/ui/badge'; interface EmailSidebarProps { currentFolder: string; - folders: string[]; - onFolderChange: (folder: string) => void; + currentAccount: string; + accounts: Array<{ + id: string; + email: string; + folders: string[]; + }>; + onFolderChange: (folder: string, accountId: string) => void; onRefresh: () => void; onCompose: () => void; isLoading: boolean; @@ -22,13 +27,15 @@ interface EmailSidebarProps { export default function EmailSidebar({ currentFolder, - folders, + currentAccount, + accounts, onFolderChange, onRefresh, onCompose, isLoading }: EmailSidebarProps) { - const [showFolders, setShowFolders] = useState(true); + const [showAccounts, setShowAccounts] = useState(true); + const [expandedAccount, setExpandedAccount] = useState(currentAccount); // Get the appropriate icon for a folder const getFolderIcon = (folder: string) => { @@ -58,14 +65,23 @@ export default function EmailSidebar({ }; // Group folders into standard and custom - const standardFolders = ['INBOX', 'Sent', 'Drafts', 'Trash', 'Archive', 'Junk']; - const visibleStandardFolders = standardFolders.filter(f => - folders.includes(f) || folders.some(folder => folder.toLowerCase() === f.toLowerCase()) - ); + const getStandardFolders = (folders: string[]) => { + const standardFolders = ['INBOX', 'Sent', 'Drafts', 'Trash', 'Archive', 'Junk']; + return standardFolders.filter(f => + folders.includes(f) || folders.some(folder => folder.toLowerCase() === f.toLowerCase()) + ); + }; - const customFolders = folders.filter(f => - !standardFolders.some(sf => sf.toLowerCase() === f.toLowerCase()) - ); + const getCustomFolders = (folders: string[]) => { + const standardFolders = ['INBOX', 'Sent', 'Drafts', 'Trash', 'Archive', 'Junk']; + return folders.filter(f => + !standardFolders.some(sf => sf.toLowerCase() === f.toLowerCase()) + ); + }; + + const handleAccountClick = (accountId: string) => { + setExpandedAccount(expandedAccount === accountId ? null : accountId); + }; return (