Fix color name detection with fuzzy matching, fix checkout syntax errors, add error handling for products page

This commit is contained in:
Andymick
2026-07-18 08:44:59 +01:00
parent c6850372cb
commit cf1d40b1c1
3 changed files with 119 additions and 94 deletions
+9 -2
View File
@@ -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">