ba830947d2
Checkout forces 0% VAT without de-grossing prices when the tenant is a Kleinunternehmer (a business decision, not just an engineering default — unlike the existing intra-community VAT exemption, which does de-gross). Snapshotted onto the order at checkout time so a later toggle of the company-settings checkbox never rewrites an already-issued invoice's tax treatment — same reasoning as the existing vatExempt field. Threaded through: checkout route, order creation/confirmation email, on-demand invoice/Storno/Gutschrift downloads, the Bestellbestätigung page, and the account order-detail page. The four storefront "inkl. X% MwSt." price hints (shop grid, cart upsell, ToDo-Karten landing page, homepage spotlight) drop that clause live when the setting is on. The company-settings Live Preview reflects the checkbox in real time too. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
70 lines
2.9 KiB
TypeScript
70 lines
2.9 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, getKleinunternehmer } 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, kleinunternehmer, showDiscountField] = await Promise.all([
|
|
getCartTrustBadges(),
|
|
getShippingMethods(),
|
|
getShippingSettings(),
|
|
getDefaultTaxRatePercent(),
|
|
getKleinunternehmer(),
|
|
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}
|
|
kleinunternehmer={kleinunternehmer}
|
|
showDiscountField={showDiscountField}
|
|
/>
|
|
</Suspense>
|
|
<RelatedProducts defaultTaxRate={defaultTaxRate} kleinunternehmer={kleinunternehmer} />
|
|
<TrustRow />
|
|
</main>
|
|
<Footer />
|
|
</>
|
|
);
|
|
}
|