import type { Metadata } from "next"; import { Container, LinkButton, SectionHeading } from "@/components/ui"; import { noIndexPrivate } from "@/lib/seo"; import { getCurrentCustomer } from "@/lib/auth"; import { resolveSubscriptionReturn } from "@/lib/sponsorship-subscription/checkout-return"; import { getLocale } from "@/i18n/locale"; import { getAboStrings } from "@/i18n/sponsorship/abo"; // Fragt bei jedem Aufruf den aktuellen Stand bei Stripe ab — nie aus einem Cache. export const dynamic = "force-dynamic"; export async function generateMetadata(): Promise { return { title: getAboStrings(await getLocale()).thanks.metaTitle, robots: noIndexPrivate }; } type Props = { searchParams: Promise> }; /** * Rueckkehrseite nach dem Abo-Checkout (return_url in checkout.ts). Ueber * "abgeschlossen" entscheidet die serverseitige Nachfrage bei Stripe, nicht * die URL; angelegt wird hier nichts — Abo, Zahlung und Urkunde entstehen * ausschliesslich ueber den Webhook. */ export default async function AboThanksPage({ searchParams }: Props) { const t = getAboStrings(await getLocale()).thanks; const { session_id: sessionId } = await searchParams; const customer = await getCurrentCustomer(); const result = typeof sessionId === "string" && customer ? await resolveSubscriptionReturn(sessionId, customer.id) : { kind: "notCompleted" as const }; const view = result.kind === "active" ? { title: t.activeTitle, text: t.activeText } : result.kind === "processing" ? { title: t.processingTitle, text: t.processingText } : { title: t.notCompletedTitle, text: t.notCompletedText }; return (

{view.text}

{result.kind === "notCompleted" ? ( {t.backToOffer} ) : ( <> {t.toSubscription} {t.toAccount} )}
); }