"use client";

import { getUserSites } from "@/lib/sites";
import { templates } from "@/lib/template";
import { notFound } from "next/navigation";

interface CartPageProps {
  params: { site: string };
}

export default function CartPage({ params }: CartPageProps) {
  if (typeof window === "undefined") return null; // SSR safe
  const userSites = getUserSites();
  const site = userSites.find((s) => s.slug === params.site);
  if (!site) return notFound();

  const Template = templates[site.template];
  const Header = Template.Header;
  const Footer = Template.Footer;
  const Cart = Template.pages.Cart;

  return (
    <>
      <Header />
      <Cart />
      <Footer />
    </>
  );
}
