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 } from "types"; export interface SubIssueListProps { issues: IIssue[]; projectId: string; workspaceSlug: string; parentIssue: IIssue; handleSubIssueRemove: (subIssueId: string) => void; } export const SubIssueList: FC = ({ issues = [], handleSubIssueRemove, parentIssue, workspaceSlug, projectId, }) => { // 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); }; return ( <> {parentIssue?.id && workspaceSlug && projectId && issues?.length > 0 ? ( {({ open }) => ( <>
Sub-issues {issues.length} {open ? (
{ setSubIssueModalActive(true); }} > Add an existing issue
) : null}
{issues.map((issue) => (
{issue.project_detail.identifier}-{issue.sequence_id} {issue.name}
handleSubIssueRemove(issue.id)}> Remove as sub-issue
))}
)}
) : ( Add sub-issue } optionsPosition="left" noBorder > { openIssueModal(); }} > Create new { openSubIssueModal(); }} > Add an existing issue )} ); };