import { redirect } from "next/navigation"; import { availableShipping } from "@/lib/checkout"; import { formatPrice } from "@/lib/money"; import { shippingPrice } from "@/lib/pricing"; import { ChoiceForm } from "@/components/shop/ChoiceForm"; import { saveShipping } from "../actions"; import { CheckoutSummary, loadCheckout } from "../shared"; export const metadata = { title: "Kasse – Versand" }; export default async function ShippingStep() { const data = await loadCheckout(); if (!data.state.address) redirect("/kasse/adresse"); const methods = await availableShipping(data.state.address.country); const merchandise = data.totals.subtotal - data.totals.discount; return (
{methods.length === 0 ? (

In dein Land können wir gerade nicht liefern. Bitte melde dich bei uns.

) : ( { const price = shippingPrice(m, merchandise); return { id: m.id, title: m.name, price: price === 0 ? "Kostenlos" : formatPrice(price), text: [m.description, m.freeFrom > 0 && price > 0 ? `Kostenlos ab ${formatPrice(m.freeFrom)}` : ""].filter(Boolean).join(" · "), }; })} /> )}
); }