import { FC, useState } from "react"; import Link from "next/link"; import { Disclosure, Transition } from "@headlessui/react"; import { ChevronRightIcon, PlusIcon } from "@heroicons/react/24/outline"; // components import { CustomMenu } from "components/ui"; import { CreateUpdateIssueModal } from "components/issues"; import AddAsSubIssue from "components/project/issues/issue-detail/add-as-sub-issue"; // types import { IIssue, UserAuth } from "types"; export interface SubIssueListProps { issues: IIssue[]; projectId: string; workspaceSlug: string; parentIssue: IIssue; handleSubIssueRemove: (subIssueId: string) => void; userAuth: UserAuth; } export const SubIssueList: FC = ({ issues = [], handleSubIssueRemove, parentIssue, workspaceSlug, projectId, userAuth, }) => { // states const [isIssueModalActive, setIssueModalActive] = useState(false); const [isSubIssueModalActive, setSubIssueModalActive] = useState(false); const [preloadedData, setPreloadedData] = useState | null>(null); const openIssueModal = () => { setIssueModalActive(true); }; const closeIssueModal = () => { setIssueModalActive(false); }; const openSubIssueModal = () => { setSubIssueModalActive(true); }; const closeSubIssueModal = () => { setSubIssueModalActive(false); }; const isNotAllowed = userAuth.isGuest || userAuth.isViewer; return ( <> {({ open }) => ( <>
Sub-issues {issues.length} {open && !isNotAllowed ? (
{ setSubIssueModalActive(true); }} > Add an existing issue
) : null}
{issues.map((issue) => (
{issue.project_detail.identifier}-{issue.sequence_id} {issue.name} {!isNotAllowed && (
handleSubIssueRemove(issue.id)}> Remove as sub-issue
)}
))}
)}
); };