From f54d680e7e28db9bca723e80485eca8130bec046 Mon Sep 17 00:00:00 2001 From: BennyKok Date: Thu, 18 Jan 2024 21:53:56 +0800 Subject: [PATCH] fix: mobile unable to change org --- web/src/components/Navbar.tsx | 30 +++++++++++++++++--- web/src/components/ui/sheet.tsx | 49 ++++++++++++++++----------------- 2 files changed, 50 insertions(+), 29 deletions(-) diff --git a/web/src/components/Navbar.tsx b/web/src/components/Navbar.tsx index ab3ccd5..7d737dd 100644 --- a/web/src/components/Navbar.tsx +++ b/web/src/components/Navbar.tsx @@ -2,6 +2,11 @@ import { NavbarMenu } from "@/components/NavbarMenu"; import { Button } from "@/components/ui/button"; +import { + Popover, + PopoverContent, + PopoverTrigger, +} from "@/components/ui/popover"; import { Sheet, SheetContent, @@ -9,13 +14,19 @@ import { SheetTitle, SheetTrigger, } from "@/components/ui/sheet"; -import { OrganizationSwitcher, UserButton } from "@clerk/nextjs"; +import { + OrganizationList, + OrganizationSwitcher, + UserButton, + useOrganization, +} from "@clerk/nextjs"; import { Github, Menu } from "lucide-react"; import meta from "next-gen/config"; import { useEffect, useState } from "react"; import { useMediaQuery } from "usehooks-ts"; export function Navbar() { + const { organization } = useOrganization(); const _isDesktop = useMediaQuery("(min-width: 1024px)"); const [isDesktop, setIsDesktop] = useState(true); useEffect(() => { @@ -37,13 +48,24 @@ export function Navbar() {
- + /> */} + + + + + + + +
diff --git a/web/src/components/ui/sheet.tsx b/web/src/components/ui/sheet.tsx index a37f17b..5c2aef7 100644 --- a/web/src/components/ui/sheet.tsx +++ b/web/src/components/ui/sheet.tsx @@ -1,19 +1,18 @@ -"use client" +"use client"; -import * as React from "react" -import * as SheetPrimitive from "@radix-ui/react-dialog" -import { cva, type VariantProps } from "class-variance-authority" -import { X } from "lucide-react" +import { cn } from "@/lib/utils"; +import * as SheetPrimitive from "@radix-ui/react-dialog"; +import { cva, type VariantProps } from "class-variance-authority"; +import { X } from "lucide-react"; +import * as React from "react"; -import { cn } from "@/lib/utils" +const Sheet = SheetPrimitive.Root; -const Sheet = SheetPrimitive.Root +const SheetTrigger = SheetPrimitive.Trigger; -const SheetTrigger = SheetPrimitive.Trigger +const SheetClose = SheetPrimitive.Close; -const SheetClose = SheetPrimitive.Close - -const SheetPortal = SheetPrimitive.Portal +const SheetPortal = SheetPrimitive.Portal; const SheetOverlay = React.forwardRef< React.ElementRef, @@ -27,8 +26,8 @@ const SheetOverlay = React.forwardRef< {...props} ref={ref} /> -)) -SheetOverlay.displayName = SheetPrimitive.Overlay.displayName +)); +SheetOverlay.displayName = SheetPrimitive.Overlay.displayName; const sheetVariants = cva( "fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500", @@ -47,7 +46,7 @@ const sheetVariants = cva( side: "right", }, } -) +); interface SheetContentProps extends React.ComponentPropsWithoutRef, @@ -71,8 +70,8 @@ const SheetContent = React.forwardRef< -)) -SheetContent.displayName = SheetPrimitive.Content.displayName +)); +SheetContent.displayName = SheetPrimitive.Content.displayName; const SheetHeader = ({ className, @@ -85,8 +84,8 @@ const SheetHeader = ({ )} {...props} /> -) -SheetHeader.displayName = "SheetHeader" +); +SheetHeader.displayName = "SheetHeader"; const SheetFooter = ({ className, @@ -99,8 +98,8 @@ const SheetFooter = ({ )} {...props} /> -) -SheetFooter.displayName = "SheetFooter" +); +SheetFooter.displayName = "SheetFooter"; const SheetTitle = React.forwardRef< React.ElementRef, @@ -111,8 +110,8 @@ const SheetTitle = React.forwardRef< className={cn("text-lg font-semibold text-foreground", className)} {...props} /> -)) -SheetTitle.displayName = SheetPrimitive.Title.displayName +)); +SheetTitle.displayName = SheetPrimitive.Title.displayName; const SheetDescription = React.forwardRef< React.ElementRef, @@ -123,8 +122,8 @@ const SheetDescription = React.forwardRef< className={cn("text-sm text-muted-foreground", className)} {...props} /> -)) -SheetDescription.displayName = SheetPrimitive.Description.displayName +)); +SheetDescription.displayName = SheetPrimitive.Description.displayName; export { Sheet, @@ -137,4 +136,4 @@ export { SheetFooter, SheetTitle, SheetDescription, -} +};