- Neues Modell Sale (Prozent oder fester Betrag, Ziel, Start/Ende in deutscher Zeit, an/aus) - Admin unter Verkauf → Sales: Liste mit Status (läuft, geplant, beendet, aus), anlegen, bearbeiten, beenden, löschen; Beispielrechnung im Formular - Shop: Sale-Preis mit Streichpreis in Listen, Suche, Startseite, Produktseite (je Variante, mit „gilt bis“), Warenkorb; Kasse und Bestellung rechnen mit dem Sale-Preis - Mehrere Sales: der günstigste zählt, keine Addition; Gutscheine weiterhin zusätzlich - Produktseite im Admin zeigt, wenn ein Sale läuft Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SvuGvHpbAQ4syfuLuRvutL
43 lines
1.8 KiB
TypeScript
43 lines
1.8 KiB
TypeScript
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 (
|
|
<main className="sm-container sm-page">
|
|
<h1 className="display-lg sm-page__title">Suche</h1>
|
|
<form className="sm-search sm-input-group" role="search" method="get" style={{ margin: "var(--space-5) 0 var(--space-7)" }}>
|
|
<label className="sm-visually-hidden" htmlFor="q">Suchbegriff</label>
|
|
<input className="sm-input" id="q" name="q" type="search" defaultValue={term} placeholder="Wonach suchst du?" autoFocus />
|
|
<button className="sm-btn sm-btn--primary" type="submit">Suchen</button>
|
|
</form>
|
|
{term && (
|
|
<p className="body" style={{ color: "var(--ink-muted)", marginBottom: "var(--space-5)" }}>
|
|
{products.length === 0 ? `Zu „${term}“ haben wir nichts gefunden. Versuch es mit einem anderen Wort.` : `${products.length} Treffer für „${term}“`}
|
|
</p>
|
|
)}
|
|
<div className="sm-grid">
|
|
{products.map((p) => <ProductCard key={p.id} product={p} />)}
|
|
</div>
|
|
</main>
|
|
);
|
|
}
|