Files
einfach-produktiv/app/cart/page.tsx
T
Marco a50524832e Move low-stock hint to badge, right-align VAT breakdown, gate cart discount field, split billing/shipping delivery method
- Removed the inline "Nur noch wenige verfügbar" text hint from
  AddToCartButton/AddToCartInlineButton (was making card heights vary in
  every grid that renders them — RelatedProducts, ProductSpotlight's CTA
  row) — now only shown via the same image-overlaid pill badge
  Ausverkauft/discount already use (position: absolute, doesn't affect
  layout). Added that badge to RelatedProducts.tsx and todo-cards'
  Pricing.tsx, which didn't have it before.
- RelatedProducts cards now also show "inkl. X% MwSt." (was missing
  entirely)
- VatBreakdown rows are now flex rows with a spacer instead of plain
  text, so every € amount right-aligns to the same edge regardless of
  how many digits the rate itself has (was visibly staggered with mixed
  7%/19% rates)
- Cart's manual discount-code field only renders when Payload actually
  has at least one active code right now (lib/discountServer.ts's new
  hasActiveDiscountCode()) — no point showing an open field that could
  never validate. An already-applied code (e.g. from an older session)
  still always shows its own result row regardless.
- Checkout's "1. Rechnungsadresse" no longer offers a Packstation option
  — a Packstation isn't a valid billing address for an invoice. Only a
  plain street address now; Packstation is only offered on the separate,
  optional "Abweichende Lieferadresse" section, which already had its own
  address/Packstation toggle.

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

68 lines
2.8 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, getDefaultTaxRatePercent } from "../lib/payload";
import { hasActiveDiscountCode } from "../lib/discountServer";
// 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, defaultTaxRate, showDiscountField] = await Promise.all([
getCartTrustBadges(),
getShippingMethods(),
getShippingSettings(),
getDefaultTaxRatePercent(),
hasActiveDiscountCode(),
]);
// 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}
defaultTaxRate={defaultTaxRate}
showDiscountField={showDiscountField}
/>
</Suspense>
<RelatedProducts defaultTaxRate={defaultTaxRate} />
<TrustRow />
</main>
<Footer />
</>
);
}