Add error handling to customers/mailing list page

This commit is contained in:
Andymick
2026-07-18 08:54:32 +01:00
parent a891acca63
commit cee1013a7a
+7 -1
View File
@@ -13,7 +13,13 @@ export default async function CustomersPage({
}: { }: {
searchParams: { sent?: string; failed?: string }; searchParams: { sent?: string; failed?: string };
}) { }) {
const entries = await prisma.mailingListEntry.findMany({ orderBy: { createdAt: 'desc' } }); let entries = [];
try {
entries = await prisma.mailingListEntry.findMany();
entries.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
} catch (err) {
console.error('Error fetching mailing list:', err);
}
const subscribedCount = entries.filter((e) => e.subscribed).length; const subscribedCount = entries.filter((e) => e.subscribed).length;
return ( return (