refactor: Creation d'un provider et d'un systeme de middleware

This commit is contained in:
Luc SORIGNET
2025-02-22 13:05:01 +01:00
parent c861239d48
commit 508847940c
18 changed files with 218 additions and 69 deletions

View File

@ -1,8 +1,8 @@
import React from 'react';
import { getMessages } from 'next-intl/server';
import { NextIntlClientProvider } from 'next-intl';
import { CsrfProvider } from '@/context/CsrfContext';
import Providers from '@/components/Providers'
import "@/css/tailwind.css";
import { headers } from 'next/headers';
export const metadata = {
title: "N3WT-SCHOOL",
@ -22,17 +22,16 @@ export const metadata = {
};
export default async function RootLayout({ children, params }) {
const { locale } = params;
const messages = await getMessages(locale); // Passez le locale ici
const headersList = headers();
const locale = headersList.get('x-locale') || 'fr';
const messages = await getMessages(locale);
return (
<html lang={locale}>
<body>
<CsrfProvider>
<NextIntlClientProvider messages={messages} locale={locale}> {/* Passez le locale ici */}
{children}
</NextIntlClientProvider>
</CsrfProvider>
<Providers messages={messages} locale={locale} session={params.session}>
{children}
</Providers>
</body>
</html>
);