// react import React from "react"; // next import { useRouter } from "next/router"; import Link from "next/link"; import Image from "next/image"; // services import userService from "lib/services/user.service"; import authenticationService from "lib/services/authentication.service"; // hooks import useUser from "lib/hooks/useUser"; // headless ui import { Menu, Transition } from "@headlessui/react"; // ui import { Spinner } from "ui"; // icons import { ChevronDownIcon, ClipboardDocumentListIcon, Cog6ToothIcon, HomeIcon, PlusIcon, RectangleStackIcon, UserGroupIcon, UserIcon, } from "@heroicons/react/24/outline"; // types import { IUser } from "types"; type Props = { sidebarCollapse: boolean; }; const workspaceLinks = [ { icon: HomeIcon, name: "Home", href: `/workspace`, }, { icon: ClipboardDocumentListIcon, name: "Projects", href: "/projects", }, { icon: RectangleStackIcon, name: "My Issues", href: "/me/my-issues", }, { icon: UserGroupIcon, name: "Members", href: "/workspace/members", }, // { // icon: InboxIcon, // name: "Inbox", // href: "#", // }, { icon: Cog6ToothIcon, name: "Settings", href: "/workspace/settings", }, ]; const userLinks = [ { name: "My Profile", href: "/me/profile", }, { name: "Workspace Invites", href: "/invitations", }, ]; const WorkspaceOptions: React.FC = ({ sidebarCollapse }) => { const { workspaces, activeWorkspace, user, mutateUser } = useUser(); const router = useRouter(); return (
{activeWorkspace?.logo && activeWorkspace.logo !== "" ? ( Workspace Logo ) : ( activeWorkspace?.name?.charAt(0) ?? "N" )}
{!sidebarCollapse && (

{activeWorkspace?.name ? activeWorkspace.name.length > 17 ? `${activeWorkspace.name.substring(0, 17)}...` : activeWorkspace.name : "Loading..."}

)}
{!sidebarCollapse && (
)}
{user?.email}
{workspaces ? ( <> {workspaces.length > 0 ? ( workspaces.map((workspace: any) => ( {({ active }) => ( )} )) ) : (

No workspace found!

)} { router.push("/create-workspace"); }} className="w-full text-xs flex items-center gap-2 px-2 py-1 text-left rounded hover:bg-gray-100" > Create Workspace ) : (
)}
{userLinks.map((link, index) => ( {link.name} ))} { await authenticationService .signOut({ refresh_token: authenticationService.getRefreshToken(), }) .then((response) => { console.log("user signed out", response); }) .catch((error) => { console.log("Failed to sign out", error); }) .finally(() => { mutateUser(); router.push("/signin"); }); }} > Sign out
{/* {!sidebarCollapse && (
{user?.avatar && user.avatar !== "" ? ( User Avatar ) : ( )}
{userLinks.map((item) => ( {(active) => ( {item.name} )} ))}
)} */}
{workspaceLinks.map((link, index) => ( ))}
); }; export default WorkspaceOptions;