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

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

export default function ShopPage({ params }: ShopPageProps) {
  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 Shop = Template.pages.Shop;

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