diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 5829b74..17c2fb4 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -159,7 +159,8 @@ "Bash(curl -s http://127.0.0.1:3000/products/awd-hoodie)", "Bash(curl -s http://127.0.0.1:3000/made-to-order)", "Bash(curl -s \"http://127.0.0.1:3000/products/awd-hoodie\")", - "Bash(git commit -m 'Fix: NavDropdown link navigation with stopPropagation *)" + "Bash(git commit -m 'Fix: NavDropdown link navigation with stopPropagation *)", + "Bash(git commit -m 'Feat: Remove all filters from products pages *)" ] } } diff --git a/src/app/made-to-order/page.tsx b/src/app/made-to-order/page.tsx index 0a3c1a3..d29d160 100644 --- a/src/app/made-to-order/page.tsx +++ b/src/app/made-to-order/page.tsx @@ -1,17 +1,9 @@ import { prisma } from '@/lib/prisma'; import { toProductDTO } from '@/lib/product'; import { fetchActivePromotions } from '@/lib/promotions'; -import { getPersonalisedPaletteColors } from '@/lib/cache'; import ProductCard from '@/components/ProductCard'; -import type { Prisma } from '@prisma/client'; type SearchParams = { - category?: string | string[]; - collection?: string | string[]; - color?: string | string[]; - min?: string; - max?: string; - q?: string; page?: string; }; @@ -23,278 +15,72 @@ function toArray(v?: string | string[]) { } export default async function ProductsPage({ searchParams }: { searchParams: SearchParams }) { - const categoryRows = await prisma.category.findMany({ - where: { showOnPersonalised: true, parentId: null }, - orderBy: { name: 'asc' }, - select: { - id: true, - name: true, - slug: true, - children: { - where: { showOnPersonalised: true }, - select: { id: true, name: true, slug: true }, - orderBy: { name: 'asc' }, - }, - }, - }); - // Build flat list of all categories (parents and children) for filtering - const allCategories = categoryRows.flatMap((parent) => [ - { value: parent.slug, label: parent.name }, - ...parent.children.map((child) => ({ value: child.slug, label: `${parent.name} > ${child.name}` })), - ]); - const CATEGORIES = allCategories; - - 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 })); - - const selectedCategories = toArray(searchParams.category); - const selectedCollections = toArray(searchParams.collection); - const selectedColors = toArray(searchParams.color); - const q = searchParams.q?.trim() ?? ''; - const minDollars = searchParams.min ? Number(searchParams.min) : undefined; - const maxDollars = searchParams.max ? Number(searchParams.max) : undefined; const currentPage = Math.max(1, Number(searchParams.page) || 1); - - // Cached palette across every personalised product - const palette = await getPersonalisedPaletteColors(); - - const where: Prisma.ProductWhereInput = { showOnPersonalised: true }; - if (selectedCategories.length) { - where.category = { in: selectedCategories }; - } - if (selectedCollections.length) { - where.collections = { some: { slug: { in: selectedCollections } } }; - } - if (selectedColors.length) { - where.AND = [{ OR: selectedColors.map((c) => ({ colors: { contains: c } })) }]; - } - if (q) { - where.name = { contains: q }; - } - if (minDollars !== undefined || maxDollars !== undefined) { - where.basePrice = { - ...(minDollars !== undefined ? { gte: Math.round(minDollars * 100) } : {}), - ...(maxDollars !== undefined ? { lte: Math.round(maxDollars * 100) } : {}), - }; - } - const activePromotions = await fetchActivePromotions(); const [rows, totalCount] = await Promise.all([ prisma.product.findMany({ - where, + where: { showOnPersonalised: true }, orderBy: { createdAt: 'asc' }, take: PRODUCTS_PER_PAGE, skip: (currentPage - 1) * PRODUCTS_PER_PAGE, }), - prisma.product.count({ where }), + prisma.product.count({ where: { showOnPersonalised: true } }), ]); const products = rows.map((p) => toProductDTO(p, activePromotions, 'personalised')); const totalPages = Math.ceil(totalCount / PRODUCTS_PER_PAGE); - const hasFilters = - selectedCategories.length > 0 || - selectedCollections.length > 0 || - selectedColors.length > 0 || - q || - minDollars !== undefined || - maxDollars !== undefined; - return (
{totalCount} template{totalCount === 1 ? '' : 's'}