panel 2 courier

This commit is contained in:
alma 2025-04-25 11:22:17 +02:00
parent 64c9b15097
commit 90d9aaafd9

View File

@ -47,7 +47,7 @@ export function Email() {
if (!isRefresh) setLoading(true);
try {
const response = await fetch('/api/mail');
const response = await fetch('/api/courrier?folder=INBOX&page=1&limit=5');
if (!response.ok) {
const errorData = await response.json();
@ -60,8 +60,8 @@ export function Email() {
throw new Error(data.error);
}
const validatedEmails = data.emails.map((email: any) => ({
id: email.id || Date.now().toString(),
const validatedEmails = (data.emails || []).map((email: any) => ({
id: email.id?.toString() || Date.now().toString(),
subject: email.subject || '(No subject)',
from: email.from || '',
fromName: email.fromName || email.from?.split('@')[0] || 'Unknown',
@ -72,7 +72,7 @@ export function Email() {
}));
setEmails(validatedEmails);
setMailUrl(data.mailUrl || 'https://espace.slm-lab.net/apps/courrier/');
setMailUrl('/courrier');
setError(null);
} catch (err) {
setError(err instanceof Error ? err.message : 'Error fetching emails');
@ -169,7 +169,7 @@ export function Email() {
<div
key={email.id}
className="p-2 hover:bg-gray-50/50 rounded-lg transition-colors cursor-pointer"
onClick={() => router.push('/mail')}
onClick={() => router.push('/courrier')}
>
<div className="flex items-center justify-between mb-1">
<span className="text-sm text-gray-600 truncate max-w-[60%]" title={email.fromName || email.from}>