From 64fb87d0ceb591a49aacad39bf5e885cab7decfa Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Tue, 19 Mar 2024 12:41:06 +0000 Subject: feature(web): Add support for demo mode --- apps/web/lib/clientConfig.tsx | 11 +++++++++++ apps/web/lib/providers.tsx | 21 ++++++++++++++------- 2 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 apps/web/lib/clientConfig.tsx (limited to 'apps/web/lib') diff --git a/apps/web/lib/clientConfig.tsx b/apps/web/lib/clientConfig.tsx new file mode 100644 index 00000000..fac76d3b --- /dev/null +++ b/apps/web/lib/clientConfig.tsx @@ -0,0 +1,11 @@ +import { createContext, useContext } from "react"; + +import type { ClientConfig } from "@hoarder/shared/config"; + +export const ClientConfigCtx = createContext({ + demoMode: false, +}); + +export function useClientConfig() { + return useContext(ClientConfigCtx); +} diff --git a/apps/web/lib/providers.tsx b/apps/web/lib/providers.tsx index db51c361..ce667f8d 100644 --- a/apps/web/lib/providers.tsx +++ b/apps/web/lib/providers.tsx @@ -7,6 +7,9 @@ import { httpBatchLink, loggerLink } from "@trpc/client"; import { SessionProvider } from "next-auth/react"; import superjson from "superjson"; +import type { ClientConfig } from "@hoarder/shared/config"; + +import { ClientConfigCtx } from "./clientConfig"; import { api } from "./trpc"; function makeQueryClient() { @@ -40,9 +43,11 @@ function getQueryClient() { export default function Providers({ children, session, + clientConfig, }: { children: React.ReactNode; session: Session | null; + clientConfig: ClientConfig; }) { const queryClient = getQueryClient(); @@ -64,12 +69,14 @@ export default function Providers({ ); return ( - - - - {children} - - - + + + + + {children} + + + + ); } -- cgit v1.2.3-70-g09d2