import '@/app/globals.css';
import { notFound } from 'next/navigation';
import { NextIntlClientProvider } from 'next-intl';
import type { IPageParams } from '@/models/layout.d';

// export const metadata: Metadata = {
//   title: 'Create Next App',
//   description: 'Generated by create next app',
// };

export default async function ErrorLayout({
  children,
  params,
}: Readonly<{
  children: React.ReactNode;
  params: IPageParams;
}>) {
  const paramsData = await params;
  const locale = paramsData.locale;
  const fontClass = locale === 'fa' ? 'font-fa' : 'font-en';
  let messages;
  try {
    messages = (await import(`../../../../messages/${locale}.json`)).default;
  } catch (error) {
    notFound();
  }

  return (
    <html lang={locale} dir={locale === 'fa' ? 'rtl' : 'ltr'}>
      <body className={`min-h-svh w-full overflow-x-hidden ${fontClass}`}>
        <NextIntlClientProvider locale={locale} messages={messages}>
          {children}
        </NextIntlClientProvider>
      </body>
    </html>
  );
}
