"use client";

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

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

export default function CheckoutPage({ params }: CheckoutPageProps) {
  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 Checkout = Template.pages.Checkout;

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