Enhance Providers component with time zone support
- Updated `RootLayout` to retrieve the user's time zone using `getTimeZone` from `next-intl/server`. - Modified the `Providers` component to accept and pass the time zone prop to `NextIntlClientProvider`, improving localization capabilities.
This commit is contained in:
@@ -6,7 +6,7 @@ import { cn } from "@/lib/utils";
|
||||
import { Providers } from "@/components/providers";
|
||||
import { InitUser } from "@/components/init-user";
|
||||
import { getAuthUser, getToken } from "@/lib/auth-server";
|
||||
import { getLocale, getMessages } from "next-intl/server";
|
||||
import { getLocale, getMessages, getTimeZone } from "next-intl/server";
|
||||
|
||||
const manrope = Manrope({ subsets: ["latin"], variable: "--font-sans" });
|
||||
|
||||
@@ -23,6 +23,7 @@ export default async function RootLayout({
|
||||
const initialToken = await getToken();
|
||||
const locale = await getLocale();
|
||||
const messages = await getMessages();
|
||||
const timeZone = await getTimeZone();
|
||||
const user = await getAuthUser();
|
||||
if (user) {
|
||||
const id = user.userId ?? String(user._id);
|
||||
@@ -59,7 +60,12 @@ export default async function RootLayout({
|
||||
></script>
|
||||
</head>
|
||||
<body className="min-h-full flex flex-col">
|
||||
<Providers initialToken={initialToken} locale={locale} messages={messages}>
|
||||
<Providers
|
||||
initialToken={initialToken}
|
||||
locale={locale}
|
||||
messages={messages}
|
||||
timeZone={timeZone}
|
||||
>
|
||||
<InitUser />
|
||||
{children}
|
||||
</Providers>
|
||||
|
||||
@@ -39,17 +39,23 @@ export function Providers({
|
||||
initialToken,
|
||||
locale,
|
||||
messages,
|
||||
timeZone,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
initialToken?: string | null;
|
||||
locale?: string;
|
||||
messages?: AbstractIntlMessages;
|
||||
timeZone?: string;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
|
||||
return (
|
||||
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
|
||||
<NextIntlClientProvider locale={locale} messages={messages}>
|
||||
<NextIntlClientProvider
|
||||
locale={locale}
|
||||
messages={messages}
|
||||
timeZone={timeZone}
|
||||
>
|
||||
<ConvexBetterAuthProvider
|
||||
client={convex}
|
||||
authClient={authClient}
|
||||
|
||||
Reference in New Issue
Block a user