MCPcopy Index your code
hub / github.com/cursor/community-plugins / UserMenu

Function UserMenu

apps/cursor/src/components/user-menu.tsx:32–172  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30};
31
32export function UserMenu() {
33 const pathname = usePathname();
34 const supabase = createClient();
35 const { setTheme, theme } = useTheme();
36 const [user, setUser] = useState<User | null>(null);
37 const [isLoading, setIsLoading] = useState(true);
38
39 const [_, setQueryStates] = useQueryStates({
40 addCompany: parseAsBoolean.withDefault(false),
41 redirect: parseAsBoolean.withDefault(false),
42 });
43
44 useEffect(() => {
45 async function getUser() {
46 setIsLoading(true);
47 const session = await supabase.auth.getSession();
48
49 if (!session.data.session) {
50 setIsLoading(false);
51 return;
52 }
53
54 const { data } = await supabase
55 .from("users")
56 .select("id, slug, name, image")
57 .eq("id", session.data.session?.user?.id)
58 .single();
59
60 setUser(data);
61 setIsLoading(false);
62 }
63
64 if (!user) {
65 getUser();
66 }
67 }, [pathname]);
68
69 const handleSignOut = async () => {
70 await supabase.auth.signOut();
71 setUser(null);
72 };
73
74 if (isLoading) {
75 return (
76 <div className="flex items-center gap-2">
77 <Skeleton className="size-6 rounded-none" />
78 </div>
79 );
80 }
81
82 return (
83 <motion.div
84 initial={{ opacity: 0 }}
85 animate={{ opacity: 1 }}
86 transition={{ duration: 0.3 }}
87 className="flex items-center gap-4"
88 >
89 {user ? (

Callers

nothing calls this directly

Calls 2

createClientFunction · 0.90
getUserFunction · 0.70

Tested by

no test coverage detected