import { getDictionary, locales } from "@/i18n";
import { Navbar } from "@/components/navbar";
import { Footer } from "@/components/footer";
import { sanityFetch } from "@/sanity/client";
import { SITE_SETTINGS_QUERY } from "@/sanity/queries";

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

export default async function LocaleLayout({
  children,
  params,
}: {
  children: React.ReactNode;
  params: Promise<{ locale: string }>;
}) {
  const { locale } = await params;
  const dict = getDictionary(locale);
  const settings = await sanityFetch(SITE_SETTINGS_QUERY, {}, null);

  return (
    <div lang={locale} className="flex min-h-screen flex-col">
      <Navbar locale={locale} dict={dict} settings={settings} />
      {/* pt-20 clears the fixed navbar; the home hero pulls itself back up
          with -mt-20 so its image runs full-bleed behind the bar. */}
      <main className="flex-1 pt-20">{children}</main>
      <Footer locale={locale} dict={dict} settings={settings} />
    </div>
  );
}
