import type { Metadata } from "next";
import Link from "next/link";
import { CheckoutView } from "@/components/checkout/CheckoutView";
import { LogoMark } from "@/components/brand/Logo";
import { isPrelaunch, PRELAUNCH_MESSAGE } from "@/lib/prelaunch";
import { requireUser } from "@/server/auth/session";

export const metadata: Metadata = { title: "تسویه حساب", robots: { index: false } };

export default async function CheckoutPage() {
  // پیش‌افتتاح: قبل از درخواست ورود، پیام «به‌زودی» (ثبت‌نام هم هنوز بسته است)
  if (isPrelaunch())
    return (
    <div className="container-z flex flex-col items-center py-16 text-center md:py-24">
      <LogoMark className="mb-8 h-16 w-auto" />
      <h1 className="text-xl font-extrabold">خرید آنلاین به‌زودی</h1>
      <p className="mt-3 max-w-md text-sm leading-7 text-muted">{PRELAUNCH_MESSAGE}</p>
      <Link href="/" className="btn-primary mt-8 px-8">دیدن محصولات</Link>
    </div>
    );
  await requireUser("/checkout");
  return (
    <div className="container-z py-6 md:py-10">
      <h1 className="text-2xl font-extrabold">تسویه حساب</h1>
      <CheckoutView />
    </div>
  );
}
