import Link from "next/link"; import { observer } from "mobx-react-lite"; import { Menu, Transition } from "@headlessui/react"; import { LogIn, LogOut, MoveLeft, Plus, User, UserPlus } from "lucide-react"; // mobx store import { useMobxStore } from "lib/mobx/store-provider"; // services import { AuthService } from "services/auth.service"; // ui import { Avatar, Tooltip } from "@plane/ui"; import { Fragment } from "react"; import { mutate } from "swr"; import { useRouter } from "next/router"; import useToast from "hooks/use-toast"; import { useTheme } from "next-themes"; const SIDEBAR_LINKS = [ { key: "create-workspace", Icon: Plus, name: "Create workspace", href: "/create-workspace", }, { key: "invitations", Icon: UserPlus, name: "Invitations", href: "/invitations", }, ]; const authService = new AuthService(); export const ProfileLayoutSidebar = observer(() => { const router = useRouter(); const { setTheme } = useTheme(); const { setToastAlert } = useToast(); const { theme: { sidebarCollapsed, toggleSidebar }, workspace: { workspaces }, user: { currentUser, currentUserSettings }, } = useMobxStore(); // redirect url for normal mode const redirectWorkspaceSlug = currentUserSettings?.workspace?.last_workspace_slug || currentUserSettings?.workspace?.fallback_workspace_slug || ""; const handleSignOut = async () => { await authService .signOut() .then(() => { mutate("CURRENT_USER_DETAILS", null); setTheme("system"); router.push("/"); }) .catch(() => setToastAlert({ type: "error", title: "Error!", message: "Failed to sign out. Please try again.", }) ); }; return (
{!sidebarCollapsed &&

My Profile

}
{!sidebarCollapsed && (
)} {!sidebarCollapsed && ( {currentUser?.email} Sign out )}
{SIDEBAR_LINKS.map((link) => (
{} {!sidebarCollapsed && link.name}
))}
{workspaces && workspaces.length > 0 && (
{!sidebarCollapsed && (
Your workspaces
)}
{workspaces.map((workspace) => ( {workspace?.logo && workspace.logo !== "" ? ( Workspace Logo ) : ( workspace?.name?.charAt(0) ?? "..." )} {!sidebarCollapsed && (

{workspace.name}

)}
))}
)}
); });