"use client"; import type { FC } from "react"; import { useState } from "react"; import { observer } from "mobx-react"; import { Menu, Transition } from "@headlessui/react"; // ui import { cn, getFileURL } from "@plane/utils"; // helpers // hooks import { useUser } from "@/hooks/store/user"; // components import { SwitchAccountModal } from "./switch-account-modal"; type TSwitchAccountDropdownProps = { fullName?: string; }; export const SwitchAccountDropdown: FC = observer((props) => { const { fullName } = props; // states const [showSwitchAccountModal, setShowSwitchAccountModal] = useState(false); // store hooks const { data: user } = useUser(); const displayName = user?.first_name ? `${user?.first_name} ${user?.last_name ?? ""}` : fullName && fullName.trim().length > 0 ? fullName : user?.email; if (!displayName && !fullName) return null; return ( <> setShowSwitchAccountModal(false)} />
{user?.avatar_url ? ( {user?.display_name} ) : ( <>{fullName?.[0] ?? "R"} )}
{displayName}
cn("text-red-500 px-1 py-1.5 whitespace-nowrap text-left rounded w-full", { "bg-custom-background-80": active, }) } onClick={() => setShowSwitchAccountModal(true)} > Wrong e-mail address?
); });