diff --git a/app/mail/page.tsx b/app/mail/page.tsx
index 8c07db7..0eb8bf0 100644
--- a/app/mail/page.tsx
+++ b/app/mail/page.tsx
@@ -122,6 +122,24 @@ export default function MailPage() {
(currentView === 'starred' ? email.starred : email.category === currentView)
);
+ // Format date for display
+ const formatDate = (dateString: string) => {
+ const date = new Date(dateString);
+ const now = new Date();
+
+ if (date.toDateString() === now.toDateString()) {
+ return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
+ } else {
+ return date.toLocaleDateString([], { month: 'short', day: 'numeric' });
+ }
+ };
+
+ // Get account color
+ const getAccountColor = (accountId: number) => {
+ const account = accounts.find(acc => acc.id === accountId);
+ return account ? account.color : 'bg-gray-500';
+ };
+
// Handle email selection
const handleEmailClick = async (emailId: number) => {
// Mark as read in IMAP
@@ -163,6 +181,34 @@ export default function MailPage() {
setEmails(updatedEmails);
};
+ // Handle bulk selection
+ const toggleEmailSelection = (emailId: number, e: React.MouseEvent) => {
+ e.stopPropagation();
+ setSelectedEmails(prev =>
+ prev.includes(emailId)
+ ? prev.filter(id => id !== emailId)
+ : [...prev, emailId]
+ );
+ setShowBulkActions(true);
+ };
+
+ // Handle select all
+ const toggleSelectAll = () => {
+ if (selectedEmails.length === filteredEmails.length) {
+ setSelectedEmails([]);
+ setShowBulkActions(false);
+ } else {
+ setSelectedEmails(filteredEmails.map(email => email.id));
+ setShowBulkActions(true);
+ }
+ };
+
+ // Handle bulk delete
+ const handleBulkDelete = () => {
+ setDeleteType('emails');
+ setShowDeleteConfirm(true);
+ };
+
// Handle delete confirmation
const handleDeleteConfirm = async () => {
try {
@@ -190,5 +236,411 @@ export default function MailPage() {
setShowDeleteConfirm(false);
};
- // Rest of the component remains exactly the same...
+ if (loading) {
+ return (
+
+
+
+
Loading your emails...
+
+
+ );
+ }
+
+ if (error) {
+ return (
+
+
+
+
{error}
+
+
+
+ );
+ }
+
+ return (
+
+ {/* Sidebar */}
+
+ {/* Logo and toggle */}
+
+ {sidebarOpen &&
Mail
}
+
+
+
+ {/* Compose button */}
+
+
+
+
+ {/* Navigation */}
+
+
+ {/* Account info */}
+
+
+
+
+ {accounts[0].email.charAt(0).toUpperCase()}
+
+
+ {sidebarOpen && (
+
+
+ {accounts[0].name}
+
+
+ {accounts[0].email}
+
+
+ )}
+
+
+
+
+ {/* Main content */}
+
+ {/* Header */}
+
+
+
+
+
+
+
+ {/* Email list */}
+
+ {filteredEmails.length > 0 ? (
+
+ {filteredEmails.map((email) => (
+
handleEmailClick(email.id)}
+ >
+
toggleEmailSelection(email.id, e)}
+ className="h-4 w-4"
+ />
+
+
+
+
+ {email.subject}
+ {formatDate(email.date)}
+
+
+
+ ))}
+
+ ) : (
+
+
+
No emails in this folder
+
+ )}
+
+
+
+ {/* Compose email modal */}
+ {composeOpen && (
+
+
+
+ New Message
+
+
+
+
+
+
+
+
+
+
+
+
+ {!showCc && (
+
+ )}
+ {!showBcc && (
+
+ )}
+
+
+
+
+ {showCc && (
+
+
+
+
+
+
+
+ )}
+ {showBcc && (
+
+
+
+
+
+
+
+ )}
+
+
+
+
+
+
+
+
+
+
+
+ {/* File Attachment Section */}
+
+
+
+
Maximum file size: 25 MB
+
+
{
+ // Handle file upload
+ console.log(e.target.files);
+ }}
+ />
+
+
+
+
+
+
+
+
+
+ )}
+
+ {/* Delete Confirmation Dialog */}
+
+
+
+ Are you sure?
+
+ {deleteType === 'email' && "This email will be moved to trash."}
+ {deleteType === 'emails' && `${selectedEmails.length} emails will be moved to trash.`}
+ {deleteType === 'account' && "This account will be permanently removed. This action cannot be undone."}
+
+
+
+ setShowDeleteConfirm(false)}>Cancel
+
+ {deleteType === 'account' ? 'Delete Account' : 'Move to Trash'}
+
+
+
+
+
+ );
}
\ No newline at end of file