"use client"; import { Fragment, useEffect, useState } from "react"; import { useTheme as useNextTheme } from "next-themes"; import { observer } from "mobx-react-lite"; import { LogOut, UserCog2, Palette } from "lucide-react"; import { Menu, Transition } from "@headlessui/react"; import { Avatar } from "@plane/ui"; // hooks import { useTheme, useUser } from "@/hooks"; // helpers import { API_BASE_URL, cn } from "@/helpers/common.helper"; // services import { AuthService } from "@/services"; // service initialization const authService = new AuthService(); export const SidebarDropdown = observer(() => { // store hooks const { isSidebarCollapsed } = useTheme(); const { currentUser, signOut } = useUser(); // hooks const { resolvedTheme, setTheme } = useNextTheme(); // state const [csrfToken, setCsrfToken] = useState(undefined); const handleThemeSwitch = () => { const newTheme = resolvedTheme === "dark" ? "light" : "dark"; setTheme(newTheme); }; const handleSignOut = () => signOut(); const getSidebarMenuItems = () => (
{currentUser?.email}
Switch to {resolvedTheme === "dark" ? "light" : "dark"} mode
Sign out
); useEffect(() => { if (csrfToken === undefined) authService.requestCSRFToken().then((data) => data?.csrf_token && setCsrfToken(data.csrf_token)); }, [csrfToken]); return (
{isSidebarCollapsed && ( {getSidebarMenuItems()} )}
{!isSidebarCollapsed && (

Instance admin

)}
{!isSidebarCollapsed && currentUser && ( {getSidebarMenuItems()} )}
); });