sanamare/src/app/(shop)/kasse/versand/page.tsx
Claude 6c784e8a30
Sanamare Shop: Grundgerüst, Storefront, Kasse, Zahlungen, Admin-Anfang
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SvuGvHpbAQ4syfuLuRvutL
2026-10-19 13:11:20 +00:00

43 lines
1.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 (
<div className="sm-checkout">
<div>
{methods.length === 0 ? (
<p className="body">In dein Land können wir gerade nicht liefern. Bitte melde dich bei uns.</p>
) : (
<ChoiceForm
action={saveShipping}
name="shippingMethodId"
legend="Wie sollen wir liefern?"
submitLabel="Weiter zur Zahlung"
selected={data.state.shippingMethodId}
choices={methods.map((m) => {
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(" · "),
};
})}
/>
)}
</div>
<CheckoutSummary data={data} />
</div>
);
}