// src/app/pricing/page.tsx — PUBLIC /pricing (allowlisted in proxy.ts).
// Server page: the session is OPTIONAL — it is resolved only to point the CTA
// at the right place (logged-in → manage plan, anonymous → signup). All
// pricing data comes from PLANS via the client component; no Stripe calls.
import { headers } from "next/headers";
import { getTranslations } from "next-intl/server";
import { PublicPricing } from "@/components/billing/public-pricing";
import { auth } from "@/lib/auth";

export const metadata = {
  title: "Pricing — SEO Insight",
  description:
    "Simple pricing that scales with you. Start with a 14-day Pro trial — no card required.",
};

export default async function Page() {
  const [session, t] = await Promise.all([
    auth.api.getSession({ headers: await headers() }),
    getTranslations("Pricing"),
  ]);

  const loggedIn = Boolean(session);
  const ctaHref = loggedIn ? "/settings/billing" : "/signup";
  const ctaLabel = loggedIn ? t("ctaGoToBilling") : t("ctaStart");

  return <PublicPricing ctaHref={ctaHref} ctaLabel={ctaLabel} />;
}
