From f1390275b012d1f59661159353a13772bc978fe0 Mon Sep 17 00:00:00 2001 From: Aslam H Date: Sun, 8 Sep 2024 00:43:48 +0700 Subject: [PATCH] chore: remove wait on clerk if it base --- web/lib/providers/jazz-provider.tsx | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/web/lib/providers/jazz-provider.tsx b/web/lib/providers/jazz-provider.tsx index 2fa33758..c7d27305 100644 --- a/web/lib/providers/jazz-provider.tsx +++ b/web/lib/providers/jazz-provider.tsx @@ -4,6 +4,7 @@ import { createJazzReactApp } from "jazz-react" import { LaAccount } from "@/lib/schema" import { useAuth, useClerk } from "@clerk/nextjs" import { useJazzClerkAuth } from "jazz-react-auth-clerk" +import { usePathname } from "next/navigation" const Jazz = createJazzReactApp({ AccountSchema: LaAccount @@ -11,7 +12,18 @@ const Jazz = createJazzReactApp({ export const { useAccount, useAccountOrGuest, useCoState, useAcceptInvite } = Jazz -export function JazzAndAuth({ children }: { children: React.ReactNode }) { +const JAZZ_PEER_URL = "wss://mesh.jazz.tools/?key=example@gmail.com" + +interface ChildrenProps { + children: React.ReactNode +} + +export function JazzAndAuth({ children }: ChildrenProps) { + const pathname = usePathname() + return pathname === "/" ? {children} : {children} +} + +export function JazzAuth({ children }: ChildrenProps) { const clerk = useClerk() const { isLoaded } = useAuth() const [authMethod, state] = useJazzClerkAuth(clerk) @@ -20,12 +32,20 @@ export function JazzAndAuth({ children }: { children: React.ReactNode }) { return ( <> - {state.errors.map(error => ( + {state.errors.map((error: string) => (
{error}
))} - + {children} ) } + +export function JazzGuest({ children }: ChildrenProps) { + return ( + + {children} + + ) +}