Files
einfach-produktiv/app/cart/page.tsx
T
Marco f0df359db4 Add password reset, order confirmation email with editable templates, and fix missing account entry points
Password reset uses Payload's built-in forgot/reset-password flow,
customized to link to this app instead of the Payload admin. Order
confirmation email and the password-reset email's wording both come from
a new Payload email-templates collection, editable without a deploy and
previewable via Live Preview at /email-preview/[type] (same mechanism as
Posts/LegalPages/Testimonials, sample data instead of a real document).

Also: order numbers get a random suffix (prevents guessing, motivated by
a considered-and-deferred guest order-lookup feature); the discount code
field only shows in the cart when a code is actually active (codes now
apply via a ?code= link instead of manual entry); and three navigation
gaps found while testing — no reachable login link with an empty cart, no
logout link anywhere, no way back from profile to order history.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-22 08:14:08 +00:00

63 lines
2.5 KiB
TypeScript

import type { Metadata } from "next";
import { Suspense } from "react";
import { CartContent } from "./components/CartContent";
import { RelatedProducts } from "./components/RelatedProducts";
import { TrustRow } from "../components/TrustRow";
import { Footer } from "../components/Footer";
import { getCartTrustBadges, getShippingMethods, getShippingSettings } from "../lib/payload";
// robots: noindex — transactional page (mirrors a specific shopper's cart
// contents), per the figma-to-nextjs skill's Step 5 guidance: indexing
// this wastes crawl budget and could surface cart state in search results.
export const metadata: Metadata = {
title: "Warenkorb",
description: "Dein Warenkorb bei einfach produktiv.",
robots: {
index: false,
follow: true,
},
};
export default async function CartPage() {
const [trustBadges, shippingMethods, shipping] = await Promise.all([
getCartTrustBadges(),
getShippingMethods(),
getShippingSettings(),
]);
// The cart doesn't ask which shipping method the shopper wants yet
// (that's /checkout) — it just estimates using the first active method
// (Standard, by sortOrder) for the sidebar's "Versand" line, and shows
// the FreeShippingBanner toward whichever active method's threshold is
// lowest/easiest to reach (Express has none — it never goes free).
const defaultShipping = shippingMethods[0] ?? null;
const thresholds = shippingMethods
.map((m) => m.freeShippingThreshold)
.filter((t): t is number => t !== null);
const freeShippingThreshold = thresholds.length > 0 ? Math.min(...thresholds) : null;
return (
<>
<main className="flex flex-col flex-1 bg-bg-base">
{/* Suspense required — CartContent uses useSearchParams() (?code=
auto-apply, see its own comment) which opts any consumer into
client-side rendering unless wrapped. fallback={null}: the cart
itself is entirely client-rendered from localStorage anyway
(see CartContent's own productsLoading handling), so there's no
meaningful server-rendered content this would flash away from. */}
<Suspense fallback={null}>
<CartContent
trustBadges={trustBadges}
shippingCost={defaultShipping?.price ?? 0}
freeShippingThreshold={freeShippingThreshold}
shippingSettings={shipping}
/>
</Suspense>
<RelatedProducts />
<TrustRow />
</main>
<Footer />
</>
);
}