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

Function MobileMenu

apps/cursor/src/components/mobile-menu.tsx:21–161  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19};
20
21export function MobileMenu() {
22 const pathname = usePathname();
23 const [isOpen, setIsOpen] = useState(false);
24 const supabase = createClient();
25 const [user, setUser] = useState<User | null>(null);
26
27 useEffect(() => {
28 async function getUser() {
29 const session = await supabase.auth.getSession();
30
31 if (!session.data.session) {
32 return;
33 }
34
35 const { data } = await supabase
36 .from("users")
37 .select("id, slug, name, image")
38 .eq("id", session.data.session?.user?.id)
39 .single();
40
41 setUser(data);
42 }
43
44 if (!user) {
45 getUser();
46 }
47 }, [pathname]);
48
49 useEffect(() => {
50 if (isOpen) {
51 document.body.style.overflow = "hidden";
52 } else {
53 document.body.style.overflow = "unset";
54 }
55 return () => {
56 document.body.style.overflow = "unset";
57 };
58 }, [isOpen]);
59
60 const handleSignOut = async () => {
61 await supabase.auth.signOut();
62 setUser(null);
63 setIsOpen(false);
64 };
65
66 return (
67 <>
68 <div className="md:hidden mr-4">
69 {user ? (
70 <Avatar
71 className="size-6 rounded-none cursor-pointer"
72 onClick={() => setIsOpen(!isOpen)}
73 >
74 <AvatarImage src={user?.image} className="rounded-none" />
75 <AvatarFallback className="rounded-md bg-muted text-xs text-foreground">
76 {user?.name?.charAt(0)}
77 </AvatarFallback>
78 </Avatar>

Callers

nothing calls this directly

Calls 3

createClientFunction · 0.90
cnFunction · 0.90
getUserFunction · 0.70

Tested by

no test coverage detected