import Link from "next/link"; import { useRouter } from "next/router"; // headless ui import { Disclosure, Transition } from "@headlessui/react"; // ui import { CustomMenu, Icon } from "components/ui"; // icons import { ChevronDownIcon, DocumentTextIcon, LinkIcon, StarIcon, TrashIcon, } from "@heroicons/react/24/outline"; import { ContrastIcon, LayerDiagonalIcon, PeopleGroupIcon, SettingIcon, ViewListIcon, } from "components/icons"; // helpers import { truncateText } from "helpers/string.helper"; import { renderEmoji } from "helpers/emoji.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: "Views", href: `/${workspaceSlug}/projects/${projectId}/views`, icon: ViewListIcon, }, { name: "Pages", href: `/${workspaceSlug}/projects/${projectId}/pages`, icon: DocumentTextIcon, }, { 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.emoji ? ( {renderEmoji(project.emoji)} ) : project.icon_prop ? (
{project.icon_prop.name}
) : ( {project?.name.charAt(0)} )} {!sidebarCollapse && (
{truncateText(project?.name, 20)}
)}
{!sidebarCollapse && ( )}
{!sidebarCollapse && ( Delete project {handleAddToFavorites && ( Add to favorites )} {handleRemoveFromFavorites && ( Remove from favorites )} Copy project link {project.archive_in > 0 && ( router.push(`/${workspaceSlug}/projects/${project?.id}/archived-issues/`) } >
Archived Issues
)}
)}
{navigation(workspaceSlug as string, project?.id).map((item) => { if ( (item.name === "Cycles" && !project.cycle_view) || (item.name === "Modules" && !project.module_view) || (item.name === "Views" && !project.issue_views_view) || (item.name === "Pages" && !project.page_view) ) return; return (
{!sidebarCollapse && item.name}
); })}
)}
); };