widget email 15

This commit is contained in:
Alma 2025-04-13 21:35:59 +02:00
parent ef5c38a42e
commit f55bba3c1b
2 changed files with 9 additions and 4 deletions

View File

@ -19,14 +19,18 @@ export async function GET(req: NextRequest) {
); );
} }
// Return the Nextcloud Mail iframe URL // Return the Nextcloud Mail iframe URL with an empty emails array
return NextResponse.json({ return NextResponse.json({
url: `${nextcloudUrl}/apps/mail/box/unified` emails: [], // Initialize with empty array
mailUrl: `${nextcloudUrl}/apps/mail/box/unified`
}); });
} catch (error) { } catch (error) {
console.error('Error getting Mail URL:', error); console.error('Error getting Mail URL:', error);
return NextResponse.json( return NextResponse.json(
{ error: "L'application Mail n'est pas disponible sur Nextcloud. Veuillez contacter votre administrateur." }, {
error: "L'application Mail n'est pas disponible sur Nextcloud. Veuillez contacter votre administrateur.",
emails: [] // Initialize with empty array even in error case
},
{ status: 404 } { status: 404 }
); );
} }

View File

@ -22,6 +22,7 @@ interface Email {
interface EmailResponse { interface EmailResponse {
emails: Email[]; emails: Email[];
mailUrl: string; mailUrl: string;
error?: string;
} }
export function Email() { export function Email() {
@ -56,7 +57,7 @@ export function Email() {
throw new Error(data.error || 'Failed to fetch emails'); throw new Error(data.error || 'Failed to fetch emails');
} }
setEmails(data.emails); setEmails(data.emails || []);
setMailUrl(data.mailUrl); setMailUrl(data.mailUrl);
setError(null); setError(null);
} catch (err) { } catch (err) {