link-stack/apps/link/app/_components/MultiProvider.tsx

44 lines
1.6 KiB
TypeScript
Raw Normal View History

2023-06-26 10:07:12 +00:00
"use client";
import { FC, PropsWithChildren, useState } from "react";
2023-06-26 10:07:12 +00:00
import { CssBaseline } from "@mui/material";
import { CookiesProvider } from "react-cookie";
import { SessionProvider } from "next-auth/react";
import { NextAppDirEmotionCacheProvider } from "tss-react/next/appDir";
2023-08-25 07:11:33 +00:00
import { I18n } from "react-polyglot";
2024-02-14 12:13:00 +01:00
import { AdapterDateFns } from "@mui/x-date-pickers-pro/AdapterDateFnsV3";
2023-06-26 10:07:12 +00:00
import { LocalizationProvider } from "@mui/x-date-pickers-pro";
2024-04-21 08:11:24 +02:00
import { LicenseInfo } from "@mui/x-license";
2024-06-05 08:52:41 +02:00
import { locales, LeafcutterProvider } from "@link-stack/leafcutter-ui";
import { CSRFProvider } from "./CSRFProvider";
2023-07-17 12:23:12 +00:00
LicenseInfo.setLicenseKey(
2024-05-16 18:22:10 +02:00
"c787ac6613c5f2aa0494c4285fe3e9f2Tz04OTY1NyxFPTE3NDYzNDE0ODkwMDAsUz1wcm8sTE09c3Vic2NyaXB0aW9uLEtWPTI=",
2023-07-17 12:23:12 +00:00
);
2023-06-26 10:07:12 +00:00
export const MultiProvider: FC<PropsWithChildren> = ({ children }) => {
const origin =
typeof window !== "undefined" && window.location.origin
? window.location.origin
: null;
2023-08-25 07:11:33 +00:00
const messages: any = { en: locales.en, fr: locales.fr };
const locale = "en";
2023-10-16 09:20:40 +02:00
2023-06-26 10:07:12 +00:00
return (
2024-05-09 07:42:44 +02:00
<NextAppDirEmotionCacheProvider options={{ key: "css" }}>
2023-06-26 10:07:12 +00:00
<CssBaseline />
<SessionProvider>
<CSRFProvider>
2024-05-09 07:42:44 +02:00
<CookiesProvider>
<LocalizationProvider dateAdapter={AdapterDateFns}>
<I18n locale={locale} messages={messages[locale]}>
<LeafcutterProvider>{children}</LeafcutterProvider>
</I18n>
</LocalizationProvider>
</CookiesProvider>
</CSRFProvider>
</SessionProvider>
2024-05-09 07:42:44 +02:00
</NextAppDirEmotionCacheProvider>
2023-06-26 10:07:12 +00:00
);
};