fb7b4eefc1
Build & Push / Build & Push Docker Image (push) Failing after 2m50s
Test / Type Check (all packages) (push) Failing after 55s
Test / API Unit Tests (push) Has been skipped
Test / Homepage Unit Tests (push) Has been skipped
Test / Carplace Unit Tests (push) Has been skipped
Test / Admin Unit Tests (push) Has been skipped
Test / Dashboard Unit Tests (push) Has been skipped
Test / API Integration Tests (push) Has been skipped
58 lines
2.5 KiB
TypeScript
58 lines
2.5 KiB
TypeScript
import type { Metadata } from 'next'
|
|
import { cookies } from 'next/headers'
|
|
import { JetBrains_Mono } from 'next/font/google'
|
|
import Script from 'next/script'
|
|
import '@fontsource-variable/inter/index.css'
|
|
import '@fontsource-variable/noto-sans-arabic/index.css'
|
|
import { DashboardI18nProvider } from '@/components/I18nProvider'
|
|
import { HOMEPAGE_THEME_COOKIE, SHARED_LANGUAGE_COOKIE, SHARED_THEME_KEY } from '@/lib/preferences'
|
|
import './globals.css'
|
|
|
|
const jetbrainsMono = JetBrains_Mono({
|
|
subsets: ['latin'],
|
|
variable: '--font-mono',
|
|
display: 'swap',
|
|
})
|
|
|
|
export const metadata: Metadata = {
|
|
title: 'RentalDriveGo Dashboard',
|
|
description: 'Manage your rental car business',
|
|
icons: {
|
|
icon: '/icon.svg',
|
|
shortcut: '/icon.svg',
|
|
},
|
|
|
|
}
|
|
|
|
function resolveInitialLanguage(value: string | undefined): 'en' | 'fr' | 'ar' {
|
|
return value === 'fr' || value === 'ar' || value === 'en' ? value : 'en'
|
|
}
|
|
|
|
export default async function RootLayout({ children }: { children: React.ReactNode }) {
|
|
const cookieStore = await cookies()
|
|
const initialLanguage = resolveInitialLanguage(
|
|
cookieStore.get(SHARED_LANGUAGE_COOKIE)?.value ?? cookieStore.get('dashboard-language')?.value,
|
|
)
|
|
const dir = initialLanguage === 'ar' ? 'rtl' : 'ltr'
|
|
const cookieTheme = cookieStore.get(SHARED_THEME_KEY)?.value ?? cookieStore.get(HOMEPAGE_THEME_COOKIE)?.value
|
|
const initialTheme = cookieTheme === 'light' ? 'light' : 'dark'
|
|
|
|
return (
|
|
<html lang={initialLanguage} dir={dir} className={initialTheme} suppressHydrationWarning>
|
|
<head>
|
|
<Script
|
|
id="dashboard-theme-bootstrap"
|
|
strategy="beforeInteractive"
|
|
dangerouslySetInnerHTML={{
|
|
__html:
|
|
"(function(){try{var q=new URLSearchParams(location.search).get('theme');var m=document.cookie.match(/(?:^|; )rentaldrivego-theme=([^;]+)/);var h=document.cookie.match(/(?:^|; )hpc-theme=([^;]+)/);var theme=(q==='light'||q==='dark')?q:(m?decodeURIComponent(m[1]):(h?decodeURIComponent(h[1]):(localStorage.getItem('rentaldrivego-theme')||localStorage.getItem('dashboard-theme')||localStorage.getItem('hpc.theme.preference')||'dark')));if(theme!=='light'&&theme!=='dark'){theme='dark'}document.documentElement.classList.remove('light','dark');document.documentElement.classList.add(theme);document.documentElement.style.colorScheme=theme}catch(e){}})();",
|
|
}}
|
|
/>
|
|
</head>
|
|
<body className={`font-sans ${jetbrainsMono.variable}`}>
|
|
<DashboardI18nProvider initialLanguage={initialLanguage}>{children}</DashboardI18nProvider>
|
|
</body>
|
|
</html>
|
|
)
|
|
}
|