import { redirect } from 'next/navigation';
import type { Metadata } from 'next';
import { getCurrentAccount } from '@/lib/account';
import { ROUTES } from '@/lib/routes';
import { CheckoutForm } from '@/components/checkout/checkout-form';

export const metadata: Metadata = { title: 'Checkout' };

export default async function CheckoutPage() {
  const account = await getCurrentAccount();

  if (!account) {
    redirect(`${ROUTES.login}?redirect=${ROUTES.checkout}`);
  }

  return (
    <section className="py-12">
      <div className="container-page max-w-4xl">
        <h1 className="font-serif text-2xl font-bold text-navy-800">Checkout</h1>
        <CheckoutForm />
      </div>
    </section>
  );
}
