- Added `UserPreferencesProvider` to `RootLayout` for centralized user preferences handling. - Updated components to remove direct user preferences fetching, relying on context instead. - Enhanced SSR data fetching by consolidating user preferences retrieval into a single service call. - Cleaned up unused props in various components to streamline the codebase.
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
import type { Metadata } from "next";
|
|
import { Geist, Geist_Mono } from "next/font/google";
|
|
import "./globals.css";
|
|
import { ThemeProvider } from "@/contexts/ThemeContext";
|
|
import { JiraConfigProvider } from "@/contexts/JiraConfigContext";
|
|
import { UserPreferencesProvider } from "@/contexts/UserPreferencesContext";
|
|
import { userPreferencesService } from "@/services/user-preferences";
|
|
|
|
const geistSans = Geist({
|
|
variable: "--font-geist-sans",
|
|
subsets: ["latin"],
|
|
});
|
|
|
|
const geistMono = Geist_Mono({
|
|
variable: "--font-geist-mono",
|
|
subsets: ["latin"],
|
|
});
|
|
|
|
export const metadata: Metadata = {
|
|
title: "Tower control",
|
|
description: "Tour de controle (Kanban, tache, daily, ...)",
|
|
};
|
|
|
|
export default async function RootLayout({
|
|
children,
|
|
}: Readonly<{
|
|
children: React.ReactNode;
|
|
}>) {
|
|
// Récupérer toutes les préférences côté serveur pour le SSR
|
|
const initialPreferences = await userPreferencesService.getAllPreferences();
|
|
|
|
return (
|
|
<html lang="en" className={initialPreferences.viewPreferences.theme}>
|
|
<body
|
|
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
|
|
>
|
|
<ThemeProvider initialTheme={initialPreferences.viewPreferences.theme}>
|
|
<JiraConfigProvider config={initialPreferences.jiraConfig}>
|
|
<UserPreferencesProvider initialPreferences={initialPreferences}>
|
|
{children}
|
|
</UserPreferencesProvider>
|
|
</JiraConfigProvider>
|
|
</ThemeProvider>
|
|
</body>
|
|
</html>
|
|
);
|
|
}
|