import type { Metadata } from "next";
import localFont from "next/font/local";

import { NextIntlClientProvider } from "next-intl";
import { getMessages } from "next-intl/server";
import Layout from "@/components/Layout";

import "../../styles/globals.scss";
import "../../styles/sweet-alert.scss";
import { WEBSITE_URL } from "@/Helper/Config";

export async function generateMetadata({
  params: { locale },
}: {
  params: { locale: string };
}) {
  return {
    title:
      locale === "en"
        ? "SHARJAH EQUESTRIAN RACING CLUB"
        : "نادي الشارقة للفروسية",
    description:
      "The Sharjah Equestrian and Racing Club, the first equestrian club in the UAE, was established in 1982 under the patronage of H.H. Sheikh Dr. Sultan Bin Mohammed Al Qasimi, Member of the Supreme Council and Ruler of Sharjah.",
  };
}

export default async function RootLayout({
  children,
  params: { locale },
}: {
  children: React.ReactNode;
  params: { locale: string };
}) {
  const messages = await getMessages();
  return (
    <html lang={locale} dir={locale === "ar" ? "rtl" : "ltr"}>
      <body>
        <NextIntlClientProvider messages={messages}>
          <Layout locale={locale}>{children}</Layout>
        </NextIntlClientProvider>
      </body>
    </html>
  );
}
