plane/web/app/provider.tsx
Prateek Shourya 7ac07b7b73
chore: app dir improvement (#4750)
* chore: remove constants package.

* fix: useRouter import in editor.

* chore: improve `peekCycle` and `peekModule` logic.

* style: update app progress bar color.
2024-06-10 19:05:32 +05:30

50 lines
1.7 KiB
TypeScript

"use client";
import { FC, ReactNode } from "react";
import dynamic from "next/dynamic";
import { AppProgressBar } from "next-nprogress-bar";
import { useTheme, ThemeProvider } from "next-themes";
import { SWRConfig } from "swr";
// ui
import { Toast } from "@plane/ui";
// constants
import { SWR_CONFIG } from "@/constants/swr-config";
//helpers
import { resolveGeneralTheme } from "@/helpers/theme.helper";
// mobx store provider
import { StoreProvider } from "@/lib/store-context";
// wrappers
import { InstanceWrapper } from "@/lib/wrappers";
// dynamic imports
const StoreWrapper = dynamic(() => import("@/lib/wrappers/store-wrapper"), { ssr: false });
const PostHogProvider = dynamic(() => import("@/lib/posthog-provider"), { ssr: false });
const CrispWrapper = dynamic(() => import("@/lib/wrappers/crisp-wrapper"), { ssr: false });
export interface IAppProvider {
children: ReactNode;
}
export const AppProvider: FC<IAppProvider> = (props) => {
const { children } = props;
// themes
const { resolvedTheme } = useTheme();
return (
<>
<AppProgressBar height="4px" color="#3F76FF" options={{ showSpinner: false }} shallowRouting />
<Toast theme={resolveGeneralTheme(resolvedTheme)} />
<StoreProvider>
<ThemeProvider themes={["light", "dark", "light-contrast", "dark-contrast", "custom"]} defaultTheme="system">
<InstanceWrapper>
<StoreWrapper>
<CrispWrapper>
<PostHogProvider>
<SWRConfig value={SWR_CONFIG}>{children}</SWRConfig>
</PostHogProvider>
</CrispWrapper>
</StoreWrapper>
</InstanceWrapper>
</ThemeProvider>
</StoreProvider>
</>
);
};