import Image from "next/image"; import { useRouter } from "next/navigation"; import { Menu, Transition } from "@headlessui/react"; import { Fragment } from "react"; import { authClient } from "@kan/auth/client"; import { useTheme } from "~/providers/theme"; import { getAvatarUrl } from "~/utils/helpers"; interface UserMenuProps { imageUrl: string | undefined; email: string; isLoading: boolean; } function classNames(...classes: string[]): string { return classes.filter(Boolean).join(" "); } export default function UserMenu({ imageUrl, email, isLoading, }: UserMenuProps) { const router = useRouter(); const { themePreference, switchTheme } = useTheme(); const handleLogout = async () => { await authClient.signOut(); router.push("/login"); }; const avatarUrl = imageUrl ? getAvatarUrl(imageUrl) : null; return (
{isLoading ? (
) : ( {avatarUrl ? ( ) : ( )} {email} )}
Theme
); }