import { getCart } from "@/lib/actions/cart";
import { computeShippingCost } from "@/lib/actions/order-math";
import CartPageClient from "./cart-page-client";

export const dynamic = "force-dynamic";

export default async function CartPage() {
  const cart = await getCart();

  // Delivery fee is derived server-side so the displayed total always matches
  // what createOrder will truly charge.
  const deliveryFee = cart ? await computeShippingCost(cart.subtotal) : 0;

  return <CartPageClient cart={cart} deliveryFee={deliveryFee} />;
}