"use client"; import { Fragment, useEffect, useState } from "react"; import { observer } from "mobx-react-lite"; import { useTheme as useNextTheme } from "next-themes"; import { LogOut, UserCog2, Palette } from "lucide-react"; import { Menu, Transition } from "@headlessui/react"; import { Avatar } from "@plane/ui"; // hooks import { API_BASE_URL, cn } from "@/helpers/common.helper"; import { useTheme, useUser } from "@/hooks/store"; // helpers // services import { AuthService } from "@/services/auth.service"; // 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()} )}
); });