Add error handling to orders page
This commit is contained in:
@@ -18,14 +18,19 @@ export default async function OrdersPage({ searchParams }: { searchParams: { arc
|
||||
|
||||
const showArchived = searchParams.archived === '1';
|
||||
|
||||
const orders = await prisma.order.findMany({
|
||||
where: {
|
||||
status: { in: ['PAID', 'PENDING', 'FAILED'] },
|
||||
archived: showArchived,
|
||||
},
|
||||
include: { items: true },
|
||||
orderBy: { createdAt: 'desc' },
|
||||
});
|
||||
let orders = [];
|
||||
try {
|
||||
orders = await prisma.order.findMany({
|
||||
where: {
|
||||
status: { in: ['PAID', 'PENDING', 'FAILED'] },
|
||||
archived: showArchived,
|
||||
},
|
||||
include: { items: true },
|
||||
});
|
||||
orders.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
|
||||
} catch (err) {
|
||||
console.error('Error fetching orders:', err);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="mx-auto max-w-4xl px-6 py-12">
|
||||
|
||||
Reference in New Issue
Block a user