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, SubIssuesListModal } from "components/issues"; // 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 SubIssuesList: FC = ({ issues = [], handleSubIssueRemove, parentIssue, workspaceSlug, projectId, userAuth, }) => { // states const [isIssueModalActive, setIssueModalActive] = useState(false); const [subIssuesListModal, setSubIssuesListModal] = useState(false); const [preloadedData, setPreloadedData] = useState | null>(null); const openIssueModal = () => { setIssueModalActive(true); }; const closeIssueModal = () => { setIssueModalActive(false); }; const openSubIssueModal = () => { setSubIssuesListModal(true); }; const closeSubIssueModal = () => { setSubIssuesListModal(false); }; const isNotAllowed = userAuth.isGuest || userAuth.isViewer; return ( <> setSubIssuesListModal(false)} parent={parentIssue} /> {({ open }) => ( <>
Sub-issues {issues.length} {open && !isNotAllowed ? (
{ setSubIssuesListModal(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
)}
))}
)}
); };