🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
fix: update TopBar component to handle session state and loading indication
Bill Yanga11246b39958
diff --git a/client/src/components/TopBar.tsx b/client/src/components/TopBar.tsxindex 58d81fdc2..71be378e2 100644--- a/client/src/components/TopBar.tsx+++ b/client/src/components/TopBar.tsx@@ -13,10 +13,11 @@ import {DropdownMenuItem,DropdownMenuTrigger,} from "./ui/dropdown-menu";+import { Skeleton } from "./ui/skeleton";import { IS_DEMO } from "../lib/const";export function TopBar() {- const session = authClient.useSession();+ const { data: session, isPending } = authClient.useSession();const router = useRouter();const queryClient = useQueryClient();@@ -24,11 +25,11 @@ export function TopBar() {<div className="flex py-2 pr-3 pl-6 items-center w-full bg-neutral-950 justify-center border-b border-neutral-750"><div className="flex items-center justify-between flex-1"><div className="flex items-center space-x-4">- <Link href={session.data ? "/" : "https://rybbit.io"}>+ <Link href={session ? "/" : "https://rybbit.io"}><Logo size="small" /></Link></div>- {session.data ? (+ {session ? (<DropdownMenu><DropdownMenuTriggerclassName="flex items-center gap-1 text-xs font-medium px-2 py-0"@@ -36,7 +37,7 @@ export function TopBar() {size="xs"><User className="w-4 h-4" />- {session.data?.user.name}+ {session?.user.name}</DropdownMenuTrigger><DropdownMenuContent align="end"><Link href="/settings/account" passHref>@@ -52,13 +53,15 @@ export function TopBar() {>Sign out</DropdownMenuItem>- {session.data.user.role === "admin" && (+ {session?.user.role === "admin" && (<Link href="/admin" passHref><DropdownMenuItem>Admin</DropdownMenuItem></Link>)}</DropdownMenuContent></DropdownMenu>+ ) : isPending ? (+ <Skeleton className="w-20 h-4 mr-2" />) : IS_DEMO ? (<Link href="https://app.rybbit.io/signup" passHref><Button variant="ghost" size="xs">