diff --git a/components/email/EmailSidebar.tsx b/components/email/EmailSidebar.tsx index 3c0eee48..45913c35 100644 --- a/components/email/EmailSidebar.tsx +++ b/components/email/EmailSidebar.tsx @@ -92,7 +92,7 @@ export default function EmailSidebar({ onClick={onCompose} > - New Email + Compose diff --git a/components/email/EmailSidebarContent.tsx b/components/email/EmailSidebarContent.tsx new file mode 100644 index 00000000..85331f40 --- /dev/null +++ b/components/email/EmailSidebarContent.tsx @@ -0,0 +1,205 @@ +'use client'; + +import React, { useState } from 'react'; +import { + Inbox, Send, Trash, Archive, Star, + File, RefreshCw, Plus, MailOpen, Settings, + ChevronDown, ChevronRight, Mail +} from 'lucide-react'; +import { Button } from '@/components/ui/button'; +import { cn } from '@/lib/utils'; +import { ScrollArea } from '@/components/ui/scroll-area'; +import { Badge } from '@/components/ui/badge'; + +interface EmailSidebarContentProps { + currentFolder: string; + currentAccount: string; + accounts: Array<{ + id: string; + email: string; + folders: string[]; + }>; + onFolderChange: (folder: string, accountId: string) => void; + onRefresh: () => void; + onCompose: () => void; + isLoading: boolean; +} + +export default function EmailSidebarContent({ + currentFolder, + currentAccount, + accounts, + onFolderChange, + onRefresh, + onCompose, + isLoading +}: EmailSidebarContentProps) { + const [showAccounts, setShowAccounts] = useState(true); + const [expandedAccount, setExpandedAccount] = useState(currentAccount); + + // Get the appropriate icon for a folder + const getFolderIcon = (folder: string) => { + const folderLower = folder.toLowerCase(); + + switch (folderLower) { + case 'inbox': + return ; + case 'sent': + case 'sent items': + return ; + case 'drafts': + return ; + case 'trash': + case 'deleted': + case 'bin': + return ; + case 'archive': + case 'archived': + return ; + case 'starred': + case 'important': + return ; + default: + return ; + } + }; + + // Group folders into standard and custom + 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 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 ( + <> + {/* Compose button area */} +
+ +
+ + {/* Accounts and folders navigation */} + +
+ {/* Accounts header with toggle */} +
+ Accounts + +
+ + {/* Accounts list */} + {showAccounts && ( +
+ {accounts.map((account) => ( +
+ {/* Account button */} + + + {/* Account folders - shown when account is expanded */} + {expandedAccount === account.id && ( +
+ {getStandardFolders(account.folders).map((folder) => ( + + ))} + + {/* Custom folders */} + {getCustomFolders(account.folders).map(folder => ( + + ))} +
+ )} +
+ ))} +
+ )} +
+
+ + {/* Settings button (bottom) */} +
+ +
+ + ); +} \ No newline at end of file