import { notFound } from 'next/navigation';
import { Nav } from '../../components/Nav';

const SUPPORTED = ['en', 'ar'] as const;

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

export default function LocaleLayout({
  children,
  params,
}: {
  children: React.ReactNode;
  params: { locale: string };
}) {
  if (!SUPPORTED.includes(params.locale as 'en' | 'ar')) notFound();
  const locale = params.locale as 'en' | 'ar';
  const isRtl = locale === 'ar';
  return (
    <div dir={isRtl ? 'rtl' : 'ltr'} lang={locale}>
      <Nav locale={locale} />
      {children}
    </div>
  );
}
