import type { Metadata } from "next";
import { notFound } from "next/navigation";
import ProjectDirectory from "@/components/public/project-directory";
import { getActiveLocale, isLocale, type Locale } from "@/lib/i18n";
import { getProjectDirectoryCopy } from "@/lib/project-content";

type WorkPageProps = {
  params: { locale: string };
  searchParams: { category?: string };
};

export function generateMetadata({ params }: { params: { locale: string } }): Metadata {
  if (!isLocale(params.locale)) return {};
  const locale = getActiveLocale(params.locale as Locale);
  const copy = getProjectDirectoryCopy(locale, "PORTFOLIO");
  return { title: copy.title, description: copy.description };
}

export default function WorkPage({ params, searchParams }: WorkPageProps) {
  if (!isLocale(params.locale)) notFound();
  const locale = getActiveLocale(params.locale as Locale);
  return <ProjectDirectory locale={locale} type="PORTFOLIO" categorySlug={searchParams.category} />;
}
