import Link from "next/link"; import { useRouter } from "next/router"; // headless ui import { Disclosure, Transition } from "@headlessui/react"; // ui import { CustomMenu } from "components/ui"; // icons import { ChevronDownIcon } from "@heroicons/react/24/outline"; import { ContrastIcon, LayerDiagonalIcon, PeopleGroupIcon, SettingIcon } from "components/icons"; // helpers import { truncateText } from "helpers/string.helper"; // types import { IProject } from "types"; type Props = { project: IProject; sidebarCollapse: boolean; handleDeleteProject: () => void; handleCopyText: () => void; handleAddToFavorites?: () => void; handleRemoveFromFavorites?: () => void; }; const navigation = (workspaceSlug: string, projectId: string) => [ { name: "Issues", href: `/${workspaceSlug}/projects/${projectId}/issues`, icon: LayerDiagonalIcon, }, { name: "Cycles", href: `/${workspaceSlug}/projects/${projectId}/cycles`, icon: ContrastIcon, }, { name: "Modules", href: `/${workspaceSlug}/projects/${projectId}/modules`, icon: PeopleGroupIcon, }, { name: "Settings", href: `/${workspaceSlug}/projects/${projectId}/settings`, icon: SettingIcon, }, ]; export const SingleSidebarProject: React.FC = ({ project, sidebarCollapse, handleDeleteProject, handleCopyText, handleAddToFavorites, handleRemoveFromFavorites, }) => { const router = useRouter(); const { workspaceSlug, projectId } = router.query; return ( {({ open }) => ( <>
{project.icon ? ( {String.fromCodePoint(parseInt(project.icon))} ) : ( {project?.name.charAt(0)} )} {!sidebarCollapse && (

{truncateText(project?.name, 20)}

)}
{!sidebarCollapse && ( )}
{!sidebarCollapse && ( Delete project {handleAddToFavorites && ( Add to favorites )} {handleRemoveFromFavorites && ( Remove from favorites )} Copy project link )}
{navigation(workspaceSlug as string, project?.id).map((item) => { if (item.name === "Cycles" && !project.cycle_view) return; if (item.name === "Modules" && !project.module_view) return; return (
{!sidebarCollapse && item.name}
); })}
)}
); };