mail page ui correction maj compose 20 bis 16

This commit is contained in:
alma 2025-04-16 14:40:19 +02:00
parent 1ed9592bcb
commit a1b39f3169

View File

@ -1042,6 +1042,130 @@ export default function MailPage() {
</nav> </nav>
); );
// Add debug logging for the email list
useEffect(() => {
console.log('Current view:', currentView);
console.log('Filtered emails:', filteredEmails.map(email => ({
id: email.id,
subject: email.subject,
folder: email.folder,
from: email.from
})));
}, [currentView, filteredEmails]);
// Email list panel section
const renderEmailList = () => (
<div className="w-[320px] bg-white/95 backdrop-blur-sm border-r border-gray-100 flex flex-col">
{/* Email list header */}
<div className="p-4 border-b border-gray-100">
<div className="flex items-center justify-between">
<div className="flex items-center gap-4">
<h2 className="text-lg font-semibold text-gray-800">
{currentView === 'INBOX' ? 'Inbox' :
currentView === 'starred' ? 'Starred' :
currentView.charAt(0).toUpperCase() + currentView.slice(1)}
</h2>
</div>
<div className="text-sm text-gray-500">
{filteredEmails.length} emails
</div>
</div>
</div>
{/* Email list */}
<div className="flex-1 overflow-y-auto">
{loading ? (
<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>
) : 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'}
{currentView === 'Drafts' && 'No drafts'}
{currentView === 'Spam' && 'No spam emails'}
{currentView === 'Archives' && 'No archived emails'}
</p>
{/* Debug info */}
<div className="text-xs text-gray-400 mt-2">
<p>Current view: {currentView}</p>
<p>Total emails: {emails.length}</p>
<p>Folders present: {[...new Set(emails.map(e => e.folder))].join(', ')}</p>
</div>
</div>
) : (
<div className="divide-y divide-gray-100">
{filteredEmails.map((email) => (
<div
key={email.id}
className={`flex flex-col p-3 hover:bg-gray-50 cursor-pointer ${
selectedEmail?.id === email.id ? 'bg-blue-50' : ''
} ${!email.read ? 'bg-blue-50/20' : ''}`}
onClick={() => handleEmailSelect(email.id)}
>
<div className="flex items-center justify-between mb-1">
<div className="flex items-center gap-3">
<Checkbox
checked={selectedEmails.includes(email.id.toString())}
onClick={(e) => e.stopPropagation()}
onCheckedChange={(checked) => {
if (checked) {
setSelectedEmails([...selectedEmails, email.id.toString()]);
} else {
setSelectedEmails(selectedEmails.filter(id => id !== email.id.toString()));
}
}}
/>
<span className="text-sm font-medium text-gray-900">
{currentView === 'Sent' ? email.to : (email.fromName || email.from)}
</span>
</div>
<div className="flex items-center gap-2">
<span className="text-xs text-gray-500">
{formatDate(email.date)}
</span>
{/* Show folder badge if it doesn't match current view */}
{email.folder !== currentView && currentView === 'starred' && (
<span className="text-xs bg-gray-100 text-gray-600 px-2 py-0.5 rounded">
{email.folder}
</span>
)}
<Button
variant="ghost"
size="sm"
className="text-gray-400 hover:text-yellow-400"
onClick={(e) => toggleStarred(email.id, e)}
>
<Star className={`h-4 w-4 ${email.starred ? 'fill-yellow-400 text-yellow-400' : ''}`} />
</Button>
</div>
</div>
<div className="ml-8">
<h3 className={`text-sm ${!email.read ? 'font-semibold' : ''} text-gray-900 mb-0.5`}>
{email.subject || '(No subject)'}
</h3>
<p className="text-xs text-gray-500 line-clamp-1">
{email.body.replace(/<[^>]*>/g, '').substring(0, 100)}...
</p>
</div>
{/* Debug info - only in development */}
{process.env.NODE_ENV === 'development' && (
<div className="ml-8 mt-1 text-xs text-gray-400">
Folder: {email.folder}
</div>
)}
</div>
))}
</div>
)}
</div>
</div>
);
if (error) { if (error) {
return ( return (
<div className="flex h-[calc(100vh-theme(spacing.12))] items-center justify-center bg-gray-100 mt-12"> <div className="flex h-[calc(100vh-theme(spacing.12))] items-center justify-center bg-gray-100 mt-12">
@ -1138,96 +1262,7 @@ export default function MailPage() {
{/* Main content area */} {/* Main content area */}
<div className="flex-1 flex overflow-hidden"> <div className="flex-1 flex overflow-hidden">
{/* Email list panel */} {/* Email list panel */}
<div className="w-[320px] bg-white/95 backdrop-blur-sm border-r border-gray-100 flex flex-col"> {renderEmailList()}
{/* Email list header */}
<div className="p-4 border-b border-gray-100">
<div className="flex items-center justify-between">
<div className="flex items-center gap-4">
<h2 className="text-lg font-semibold text-gray-800 capitalize">
{currentView}
</h2>
</div>
<div className="text-sm text-gray-500">
{filteredEmails.length} emails
</div>
</div>
</div>
{/* Email list */}
<div className="flex-1 overflow-y-auto">
{loading ? (
<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>
) : 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>
{/* Add debug info */}
<p className="text-xs text-gray-400 mt-2">
Total emails: {emails.length}
</p>
</div>
) : (
<div className="divide-y divide-gray-100">
{filteredEmails.map((email) => (
<div
key={email.id}
className={`flex flex-col p-3 hover:bg-gray-50 cursor-pointer ${
selectedEmail?.id === email.id ? 'bg-blue-50' : ''
} ${!email.read ? 'bg-blue-50/20' : ''}`}
onClick={() => handleEmailSelect(email.id)}
>
<div className="flex items-center justify-between mb-1">
<div className="flex items-center gap-3">
<Checkbox
checked={selectedEmails.includes(email.id.toString())}
onClick={(e) => e.stopPropagation()}
onCheckedChange={(checked) => {
if (checked) {
setSelectedEmails([...selectedEmails, email.id.toString()]);
} else {
setSelectedEmails(selectedEmails.filter(id => id !== email.id.toString()));
}
}}
/>
<span className="text-sm font-medium text-gray-900">
{currentView === 'Sent' ? email.to : (email.fromName || email.from)}
</span>
</div>
<div className="flex items-center gap-2">
<span className="text-xs text-gray-500">
{formatDate(email.date)}
</span>
<Button
variant="ghost"
size="sm"
className="text-gray-400 hover:text-yellow-400"
onClick={(e) => toggleStarred(email.id, e)}
>
<Star className={`h-4 w-4 ${email.starred ? 'fill-yellow-400 text-yellow-400' : ''}`} />
</Button>
</div>
</div>
<div className="ml-8">
<h3 className={`text-sm ${!email.read ? 'font-semibold' : ''} text-gray-900 mb-0.5`}>
{email.subject}
</h3>
<p className="text-xs text-gray-500 line-clamp-1">
{email.body.replace(/<[^>]*>/g, '').substring(0, 100)}...
</p>
</div>
</div>
))}
</div>
)}
</div>
</div>
{/* Preview panel - will automatically take remaining space */} {/* Preview panel - will automatically take remaining space */}
<div className="flex-1 bg-white/95 backdrop-blur-sm flex flex-col"> <div className="flex-1 bg-white/95 backdrop-blur-sm flex flex-col">