fix: theme in preferences and SSR GET

This commit is contained in:
Julien Froidefond
2025-09-17 08:49:41 +02:00
parent fdaf47c1e5
commit 748888819b
3 changed files with 44 additions and 6 deletions

View File

@@ -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>