Feat: Performance optimization and UI improvements

- Add database indexes for category, collection, and product queries (7 indexes)
- Implement in-memory caching with 5-minute TTL for categories and collections
- Convert Personalised dropdown to hierarchical sections matching Products dropdown
- Fix Reveal component React hook initialization with mounted state
- Fix Prisma query validation errors (include + select conflicts)
- Optimize product page queries to use selective field selection
- Add edit functionality for categories with parent category and visibility toggles

Performance improvement: 27-31s → 17-18s page load time (~40% faster)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
Andymick
2026-07-21 19:04:50 +01:00
co-authored by Claude Haiku 4.5
parent 396dbb93f0
commit 2dddf7d27a
16 changed files with 401 additions and 88 deletions
+5 -1
View File
@@ -31,7 +31,10 @@ export default async function ProductsPage({ searchParams }: { searchParams: Sea
]);
const CATEGORIES = allCategories;
const collectionRows = await prisma.collection.findMany({ orderBy: { name: 'asc' } });
const collectionRows = await prisma.collection.findMany({
select: { slug: true, name: true, group: true },
orderBy: { name: 'asc' },
});
const OCCASIONS = collectionRows.filter((c) => c.group === 'OCCASION').map((c) => ({ value: c.slug, label: c.name }));
const RECIPIENTS = collectionRows.filter((c) => c.group === 'RECIPIENT').map((c) => ({ value: c.slug, label: c.name }));
@@ -47,6 +50,7 @@ export default async function ProductsPage({ searchParams }: { searchParams: Sea
const allProducts = await prisma.product.findMany({
where: { showOnPersonalised: true },
select: { colors: true },
take: 10000,
});
const paletteSet = new Set<string>();
for (const p of allProducts) {