mail page ui correction maj compose 20 bis
This commit is contained in:
parent
fe7cbf5ff4
commit
0bd399039b
@ -466,28 +466,22 @@ export default function MailPage() {
|
|||||||
const [attachments, setAttachments] = useState<Attachment[]>([]);
|
const [attachments, setAttachments] = useState<Attachment[]>([]);
|
||||||
const [folders, setFolders] = useState<string[]>([]);
|
const [folders, setFolders] = useState<string[]>([]);
|
||||||
|
|
||||||
// Update the filteredEmails logic
|
// Update the filteredEmails logic to match how Inbox works
|
||||||
const filteredEmails = useMemo(() => {
|
const filteredEmails = useMemo(() => {
|
||||||
return emails.filter(email => {
|
if (!emails) return [];
|
||||||
// First filter by account if one is selected
|
|
||||||
if (selectedAccount && selectedAccount.id !== 0) {
|
|
||||||
if (email.accountId !== selectedAccount.id) return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Then filter by current view
|
|
||||||
switch (currentView) {
|
switch (currentView) {
|
||||||
case 'inbox':
|
case 'inbox':
|
||||||
return !email.deleted && !email.category?.includes('sent');
|
return emails; // This is working, so let's use similar logic for others
|
||||||
case 'starred':
|
case 'starred':
|
||||||
return !email.deleted && email.starred === true;
|
return emails.filter(email => email.starred);
|
||||||
case 'sent':
|
case 'sent':
|
||||||
return !email.deleted && email.category?.includes('sent');
|
return emails.filter(email => email.from === selectedAccount?.email);
|
||||||
case 'trash':
|
case 'trash':
|
||||||
return email.deleted === true;
|
return emails.filter(email => email.deleted);
|
||||||
default:
|
default:
|
||||||
return false;
|
return emails;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}, [emails, currentView, selectedAccount]);
|
}, [emails, currentView, selectedAccount]);
|
||||||
|
|
||||||
// Move getSelectedEmail inside the component
|
// Move getSelectedEmail inside the component
|
||||||
@ -1041,26 +1035,39 @@ export default function MailPage() {
|
|||||||
{/* Email list header */}
|
{/* Email list header */}
|
||||||
<div className="p-4 border-b border-gray-100">
|
<div className="p-4 border-b border-gray-100">
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-4">
|
||||||
{emails.length > 0 && (
|
{emails.length > 0 && (
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={selectedEmails.length === emails.length}
|
checked={selectedEmails.length === emails.length}
|
||||||
onCheckedChange={toggleSelectAll}
|
onCheckedChange={toggleSelectAll}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<span className="text-sm text-gray-500">
|
<h2 className="text-lg font-semibold text-gray-800 capitalize">
|
||||||
|
{currentView}
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
<div className="text-sm text-gray-500">
|
||||||
{filteredEmails.length} emails
|
{filteredEmails.length} emails
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Email list with proper spacing and layout */}
|
{/* Email list */}
|
||||||
<div className="flex-1 overflow-y-auto">
|
<div className="flex-1 overflow-y-auto">
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<div className="flex items-center justify-center h-64">
|
<div className="flex items-center justify-center h-64">
|
||||||
<div className="animate-spin rounded-full h-8 w-8 border-t-2 border-b-2 border-blue-500"></div>
|
<div className="animate-spin rounded-full h-8 w-8 border-t-2 border-b-2 border-blue-500"></div>
|
||||||
</div>
|
</div>
|
||||||
|
) : filteredEmails.length === 0 ? (
|
||||||
|
<div className="flex flex-col items-center justify-center h-64">
|
||||||
|
<Mail className="h-8 w-8 text-gray-400 mb-2" />
|
||||||
|
<p className="text-gray-500 text-sm">
|
||||||
|
{currentView === 'inbox' && 'No emails in inbox'}
|
||||||
|
{currentView === 'starred' && 'No starred emails'}
|
||||||
|
{currentView === 'sent' && 'No sent emails'}
|
||||||
|
{currentView === 'trash' && 'No emails in trash'}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="divide-y divide-gray-100">
|
<div className="divide-y divide-gray-100">
|
||||||
{filteredEmails.map((email) => (
|
{filteredEmails.map((email) => (
|
||||||
@ -1071,7 +1078,6 @@ export default function MailPage() {
|
|||||||
} ${!email.read ? 'bg-blue-50/20' : ''}`}
|
} ${!email.read ? 'bg-blue-50/20' : ''}`}
|
||||||
onClick={() => handleEmailSelect(email.id)}
|
onClick={() => handleEmailSelect(email.id)}
|
||||||
>
|
>
|
||||||
{/* Email header with checkbox and date */}
|
|
||||||
<div className="flex items-center justify-between mb-1">
|
<div className="flex items-center justify-between mb-1">
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
@ -1086,7 +1092,7 @@ export default function MailPage() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<span className="text-sm font-medium text-gray-900">
|
<span className="text-sm font-medium text-gray-900">
|
||||||
{email.fromName || email.from}
|
{currentView === 'sent' ? email.to : (email.fromName || email.from)}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
@ -1103,8 +1109,6 @@ export default function MailPage() {
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Email subject and preview */}
|
|
||||||
<div className="ml-8">
|
<div className="ml-8">
|
||||||
<h3 className={`text-sm ${!email.read ? 'font-semibold' : ''} text-gray-900 mb-0.5`}>
|
<h3 className={`text-sm ${!email.read ? 'font-semibold' : ''} text-gray-900 mb-0.5`}>
|
||||||
{email.subject}
|
{email.subject}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user