'use client';

import '@/styles/tailwind.css'
import { ReduxProvider } from '@/redux/provider';
import { NextIntlClientProvider } from 'next-intl';
import { notFound } from 'next/navigation';
import { ReactNode } from 'react'
import { Metadata } from 'next';

// i18n
export function generateStaticParams() {
  return [{locale: 'en'}, {locale: 'ar'}];
}

// this is the root app layout
export default async function RootLayout({children, params: {locale}} : {children : ReactNode , params : {locale : string} }) {

  // get the messages ( i18n ) for the current local
  let messages;
  try {
    messages = (await import(`@/messages/${locale}.json`)).default;
  } catch (error) {
    notFound();
  }

  return (
    <html lang={locale} dir={['ar' , 'fa'].includes(locale) ? 'rtl' : 'ltr'}>
      <body>
        <link rel="icon" href="/favicon.ico" sizes="any" />
        <NextIntlClientProvider locale={locale} messages={messages}>
          <ReduxProvider>
              {children}
          </ReduxProvider>
        </NextIntlClientProvider>
      </body>
    </html>
  );
}