"use client";

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

interface ProductPageProps {
  params: { site: string; id: string };
}

export default function ProductPage({ params }: ProductPageProps) {
  if (typeof window === "undefined") return null;
  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 Product = Template.pages.Product;

  return (
    <>
      <Header />
      <Product params={{ id: params.id }} />
      <Footer />
    </>
  );
}
