panel 2 courier
This commit is contained in:
parent
64c9b15097
commit
90d9aaafd9
@ -47,7 +47,7 @@ export function Email() {
|
|||||||
if (!isRefresh) setLoading(true);
|
if (!isRefresh) setLoading(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/api/mail');
|
const response = await fetch('/api/courrier?folder=INBOX&page=1&limit=5');
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
const errorData = await response.json();
|
const errorData = await response.json();
|
||||||
@ -60,8 +60,8 @@ export function Email() {
|
|||||||
throw new Error(data.error);
|
throw new Error(data.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
const validatedEmails = data.emails.map((email: any) => ({
|
const validatedEmails = (data.emails || []).map((email: any) => ({
|
||||||
id: email.id || Date.now().toString(),
|
id: email.id?.toString() || Date.now().toString(),
|
||||||
subject: email.subject || '(No subject)',
|
subject: email.subject || '(No subject)',
|
||||||
from: email.from || '',
|
from: email.from || '',
|
||||||
fromName: email.fromName || email.from?.split('@')[0] || 'Unknown',
|
fromName: email.fromName || email.from?.split('@')[0] || 'Unknown',
|
||||||
@ -72,7 +72,7 @@ export function Email() {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
setEmails(validatedEmails);
|
setEmails(validatedEmails);
|
||||||
setMailUrl(data.mailUrl || 'https://espace.slm-lab.net/apps/courrier/');
|
setMailUrl('/courrier');
|
||||||
setError(null);
|
setError(null);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err instanceof Error ? err.message : 'Error fetching emails');
|
setError(err instanceof Error ? err.message : 'Error fetching emails');
|
||||||
@ -169,7 +169,7 @@ export function Email() {
|
|||||||
<div
|
<div
|
||||||
key={email.id}
|
key={email.id}
|
||||||
className="p-2 hover:bg-gray-50/50 rounded-lg transition-colors cursor-pointer"
|
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">
|
<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}>
|
<span className="text-sm text-gray-600 truncate max-w-[60%]" title={email.fromName || email.from}>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user