import { Dropdown, Menu, MenuButton, MenuItem } from "@mui/joy"; import { LogOutIcon, User2Icon, SmileIcon } from "lucide-react"; import { authServiceClient } from "@/grpcweb"; import useCurrentUser from "@/hooks/useCurrentUser"; import useNavigateTo from "@/hooks/useNavigateTo"; import { Routes } from "@/router"; import { cn } from "@/utils"; import { useTranslate } from "@/utils/i18n"; import UserAvatar from "./UserAvatar"; interface Props { collapsed?: boolean; } const UserBanner = (props: Props) => { const { collapsed } = props; const t = useTranslate(); const navigateTo = useNavigateTo(); const currentUser = useCurrentUser(); const handleSignOut = async () => { await authServiceClient.signOut({}); window.location.href = Routes.AUTH; }; return (
navigateTo(currentUser ? Routes.ROOT : Routes.EXPLORE)} > {currentUser.avatarUrl ? ( ) : ( )} {!collapsed && ( {currentUser.nickname || currentUser.username} )}
navigateTo(`/u/${encodeURIComponent(currentUser.username)}`)}> {t("common.profile")} {t("common.sign-out")}
); }; export default UserBanner;