Add error handling to customers/mailing list page
This commit is contained in:
@@ -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 (
|
||||||
|
|||||||
Reference in New Issue
Block a user