import type { Metadata } from "next"; import { redirect } from "next/navigation"; import { Container, SectionHeading, LinkButton } from "@/components/ui"; import { BackLink } from "@/components/back-link"; import { AccountEmptyState } from "@/components/account-ui"; import { getCurrentCustomer } from "@/lib/auth"; import { listOwnedSponsorships } from "@/lib/sponsorship/access"; import { hasActiveOffers } from "@/lib/sponsorship/offers"; import { getCustomerLoyalty } from "@/lib/loyalty"; import { getLocale } from "@/i18n/locale"; import { getAccountSponsorshipStrings } from "@/i18n/sponsorship/account"; import { MedalShelf } from "./_components/medal-shelf"; import { SponsorshipRow } from "./_components/sponsorship-row"; import { PendingRefresher } from "./_components/pending-refresher"; import { BeeSealIcon } from "./_components/icons"; export const dynamic = "force-dynamic"; export async function generateMetadata(): Promise { return { title: getAccountSponsorshipStrings(await getLocale()).overview.metaTitle }; } export default async function KontoPatenschaftPage() { const locale = await getLocale(); const t = getAccountSponsorshipStrings(locale); const customer = await getCurrentCustomer(); if (!customer) redirect("/konto"); const [sponsorships, loyalty] = await Promise.all([ listOwnedSponsorships(customer.id, locale), getCustomerLoyalty(customer.id, locale), ]); // Widerrufene ohne Urkunde werden nie mehr fertig — kein Dauer-Neuladen. const hasPending = sponsorships.some((sponsorship) => sponsorship.revision === null && sponsorship.lifecycle !== "REVOKED"); return (
{sponsorships.length === 0 ? ( } title={t.overview.emptyTitle} description={t.overview.emptyDescription} action={(await hasActiveOffers()) ? {t.overview.emptyAction} : undefined} /> ) : null} {sponsorships.length > 0 ? (

{t.overview.listTitle}

{hasPending ? (

) : null}
    {sponsorships.map((sponsorship, index) => ( ))}
) : null} {sponsorships.length > 0 || loyalty.regular.level || loyalty.subscription?.level ? ( ) : null} {hasPending ? : null}
); }