mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
188f8ff83f
* Add sortable, radio and typography components * Remove stray css classes * Prevent drag of items from other draggable * Minor cleanup * Update yarn.lock * Remove radio input component as it was build on headless ui v2.0.0 and now we are using v1.7.0 * Fix build errors * Update dependencies in use memo.
67 lines
2.2 KiB
TypeScript
67 lines
2.2 KiB
TypeScript
import { FC, ReactNode } from "react";
|
|
import { observer } from "mobx-react";
|
|
import dynamic from "next/dynamic";
|
|
import Router from "next/router";
|
|
import { useTheme } from "next-themes";
|
|
import NProgress from "nprogress";
|
|
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";
|
|
// hooks
|
|
import { useInstance, useWorkspace, useUser } from "@/hooks/store";
|
|
// 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 });
|
|
// nprogress
|
|
NProgress.configure({ showSpinner: false });
|
|
Router.events.on("routeChangeStart", NProgress.start);
|
|
Router.events.on("routeChangeError", NProgress.done);
|
|
Router.events.on("routeChangeComplete", NProgress.done);
|
|
|
|
export interface IAppProvider {
|
|
children: ReactNode;
|
|
}
|
|
|
|
export const AppProvider: FC<IAppProvider> = observer((props) => {
|
|
const { children } = props;
|
|
// store hooks
|
|
const { config } = useInstance();
|
|
const {
|
|
data: currentUser,
|
|
membership: { currentProjectRole, currentWorkspaceRole },
|
|
} = useUser();
|
|
const { currentWorkspace } = useWorkspace();
|
|
// themes
|
|
const { resolvedTheme } = useTheme();
|
|
|
|
return (
|
|
<>
|
|
<InstanceWrapper>
|
|
<StoreWrapper>
|
|
<CrispWrapper user={currentUser}>
|
|
<PostHogProvider
|
|
user={currentUser}
|
|
currentWorkspaceId={currentWorkspace?.id}
|
|
workspaceRole={currentWorkspaceRole}
|
|
projectRole={currentProjectRole}
|
|
posthogAPIKey={config?.posthog_api_key || undefined}
|
|
posthogHost={config?.posthog_host || undefined}
|
|
>
|
|
{/* TODO: Need to handle custom themes for toast */}
|
|
<Toast theme={resolveGeneralTheme(resolvedTheme)} />
|
|
<SWRConfig value={SWR_CONFIG}>{children}</SWRConfig>
|
|
</PostHogProvider>
|
|
</CrispWrapper>
|
|
</StoreWrapper>
|
|
</InstanceWrapper>
|
|
</>
|
|
);
|
|
});
|