import { ReactNode } from "react";
import { notFound } from "next/navigation";
import { locales } from "@/i18n.config";

export function generateStaticParams() {
  return locales.map((locale) => ({ locale }));
}

interface LocaleLayoutProps {
  children: ReactNode;
  params: Promise<{
    locale: string;
  }>;
}

async function LocaleLayout({ children, params }: LocaleLayoutProps) {
  const { locale } = await params;

  if (!locales.includes(locale as any)) {
    notFound();
  }

  return <>{children}</>;
}

export default LocaleLayout;
