Fix color name detection with fuzzy matching, fix checkout syntax errors, add error handling for products page
This commit is contained in:
@@ -12,8 +12,15 @@ export default async function AdminProductsPage({
|
||||
searchParams: { error?: string };
|
||||
}) {
|
||||
const activePromotions = await fetchActivePromotions();
|
||||
const rows = await prisma.product.findMany({ orderBy: { createdAt: 'desc' } });
|
||||
const products = rows.map((p) => toProductDTO(p, activePromotions));
|
||||
let products = [];
|
||||
try {
|
||||
const rows = await prisma.product.findMany();
|
||||
products = rows.map((p) => toProductDTO(p, activePromotions)).sort((a, b) =>
|
||||
new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
|
||||
);
|
||||
} catch (err) {
|
||||
console.error('Error fetching products:', err);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="mx-auto max-w-4xl px-6 py-12">
|
||||
|
||||
Reference in New Issue
Block a user