import { notFound } from "next/navigation";
import { ShopView, type ShopParams } from "@/components/ShopView";
import { getCategories } from "@/lib/data";

export async function generateMetadata({ params }: { params: Promise<{ slug: string }> }) {
  const { slug } = await params;
  const c = (await getCategories()).find((x) => x.slug === slug);
  return { title: c?.name || "Category", description: c?.description, alternates: { canonical: `/category/${slug}` } };
}
export default async function Cat({ params, searchParams }: { params: Promise<{ slug: string }>; searchParams: Promise<ShopParams> }) {
  const { slug } = await params;
  const c = (await getCategories()).find((x) => x.slug === slug);
  if (!c) notFound();
  return <ShopView sp={await searchParams} title={c.name} forcedCategory={slug} />;
}
