fix: theme in preferences and SSR GET
This commit is contained in:
@@ -2,6 +2,7 @@ import type { Metadata } from "next";
|
||||
import { Geist, Geist_Mono } from "next/font/google";
|
||||
import "./globals.css";
|
||||
import { ThemeProvider } from "@/contexts/ThemeContext";
|
||||
import { userPreferencesService } from "@/services/user-preferences";
|
||||
|
||||
const geistSans = Geist({
|
||||
variable: "--font-geist-sans",
|
||||
@@ -18,17 +19,20 @@ export const metadata: Metadata = {
|
||||
description: "Tour de controle (Kanban, tache, daily, ...)",
|
||||
};
|
||||
|
||||
export default function RootLayout({
|
||||
export default async function RootLayout({
|
||||
children,
|
||||
}: Readonly<{
|
||||
children: React.ReactNode;
|
||||
}>) {
|
||||
// Récupérer uniquement le thème côté serveur pour le SSR (optimisé)
|
||||
const initialTheme = await userPreferencesService.getTheme();
|
||||
|
||||
return (
|
||||
<html lang="en">
|
||||
<html lang="en" className={initialTheme}>
|
||||
<body
|
||||
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
|
||||
>
|
||||
<ThemeProvider>
|
||||
<ThemeProvider initialTheme={initialTheme}>
|
||||
{children}
|
||||
</ThemeProvider>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user