import { db } from "@/lib/db"; import { withSales } from "@/lib/sales"; import { ProductCard } from "@/components/shop/ProductCard"; export const metadata = { title: "Suche" }; export default async function SearchPage({ searchParams }: { searchParams: Promise<{ q?: string }> }) { const { q = "" } = await searchParams; const term = q.trim(); const products = term ? await db.product.findMany({ where: { active: true, OR: [ { name: { contains: term, mode: "insensitive" } }, { subtitle: { contains: term, mode: "insensitive" } }, { description: { contains: term, mode: "insensitive" } }, { sku: { contains: term, mode: "insensitive" } }, ], }, include: { variants: true }, take: 48, }).then(withSales) : []; return (

Suche

{term && (

{products.length === 0 ? `Zu „${term}“ haben wir nichts gefunden. Versuch es mit einem anderen Wort.` : `${products.length} Treffer für „${term}“`}

)}
{products.map((p) => )}
); }