import { getCurrentCustomer } from '@/lib/auth';
import CheckoutPageClient from './client';

export default async function CheckoutPage() {
  let customer = null;
  try {
    customer = await getCurrentCustomer();
  } catch (err) {
    console.error('Error fetching customer for checkout:', err);
  }

  return (
    <CheckoutPageClient
      isLoggedIn={!!customer}
      customer={customer}
      customerAddress={customer ? {
        phone: customer.phone,
        addressLine1: customer.addressLine1,
        addressLine2: customer.addressLine2,
        city: customer.city,
        postalCode: customer.postalCode,
        country: customer.country,
      } : undefined}
    />
  );
}
