---
import Layout from '../layouts/Layout.astro';
import Header from '../components/layout/Header';
import CheckoutForm from '../components/checkout/CheckoutForm';
import CartDrawer from '../components/cart/CartDrawer';
import CartBadge from '../components/cart/CartBadge';

const token = Astro.cookies.get('session')?.value;
// Redirect if not logged in
if (!token) {
  return Astro.redirect('/login?redirect=/checkout');
}
---

<Layout title="ชำระเงิน">
  <Header />
  
  <div class="container mx-auto px-4 py-8">
    <h1 class="text-2xl font-bold mb-8">ชำระเงิน</h1>
    <CheckoutForm client:load />
  </div>
  
  <CartDrawer client:load />
  <CartBadge client:load />
</Layout>
