()
| 25 | ]; |
| 26 | |
| 27 | export default function UserAccountDropDown() { |
| 28 | const { data: session, status } = useSession(); |
| 29 | const user = session?.user; |
| 30 | const router = useRouter(); |
| 31 | const [isOpen, setIsOpen] = useState(false); |
| 32 | const [mounted, setMounted] = useState(false); |
| 33 | |
| 34 | useEffect(() => { |
| 35 | setMounted(true); |
| 36 | }, []); |
| 37 | |
| 38 | if (!mounted || status === "loading") return null; |
| 39 | if (!user) return null; |
| 40 | |
| 41 | return ( |
| 42 | <DropdownMenu onOpenChange={setIsOpen}> |
| 43 | <DropdownMenuTrigger asChild> |
| 44 | <Button |
| 45 | variant="ghost" |
| 46 | className="bg-secondary/15 hover:bg-secondary/25 flex items-center gap-2 rounded-xl px-3 py-2 shadow-sm transition-all duration-200 hover:shadow-md" |
| 47 | > |
| 48 | <div className="border-primary/20 h-8 w-8 overflow-hidden rounded-full border-2"> |
| 49 | {user.image ? ( |
| 50 | <UserImage image={user.image} /> |
| 51 | ) : ( |
| 52 | <div className="from-primary-400 to-primary-600 flex h-full w-full items-center justify-center bg-gradient-to-br text-white"> |
| 53 | <UserRound size={16} /> |
| 54 | </div> |
| 55 | )} |
| 56 | </div> |
| 57 | </Button> |
| 58 | </DropdownMenuTrigger> |
| 59 | |
| 60 | <AnimatePresence> |
| 61 | {isOpen && ( |
| 62 | <DropdownMenuContent |
| 63 | forceMount |
| 64 | className="bg-secondary/15 border-primary/10 rounded-2xl border p-2 shadow-lg shadow-neutral-600/5 backdrop-blur-lg" |
| 65 | align="end" |
| 66 | > |
| 67 | <motion.div |
| 68 | initial={{ opacity: 0, y: -10 }} |
| 69 | animate={{ opacity: 1, y: 0 }} |
| 70 | exit={{ opacity: 0, y: -10 }} |
| 71 | transition={{ duration: 0.2 }} |
| 72 | > |
| 73 | <DropdownMenuLabel className="flex items-center space-x-3 p-3"> |
| 74 | <div className="border-primary/20 h-12 w-12 overflow-hidden rounded-full border-2"> |
| 75 | {user.image ? ( |
| 76 | <UserImage image={user.image} /> |
| 77 | ) : ( |
| 78 | <div className="from-primary-400 to-primary-600 flex h-full w-full items-center justify-center bg-gradient-to-br text-white"> |
| 79 | <UserRound size={24} /> |
| 80 | </div> |
| 81 | )} |
| 82 | </div> |
| 83 | <div className="flex flex-col"> |
| 84 | <span className="text-foreground font-semibold">{user.name}</span> |
nothing calls this directly
no outgoing calls
no test coverage detected