import { FC } from "react"; import useSWR from "swr"; // components // hooks import { useIssueDetail } from "hooks/store"; // types import { TIssue } from "@plane/types"; import { IssueParentSiblingItem } from "./sibling-item"; export type TIssueParentSiblings = { currentIssue: TIssue; parentIssue: TIssue; }; export const IssueParentSiblings: FC = (props) => { const { currentIssue, parentIssue } = props; // hooks const { peekIssue, fetchSubIssues, subIssues: { subIssuesByIssueId }, } = useIssueDetail(); const { isLoading } = useSWR( peekIssue && parentIssue && parentIssue.project_id ? `ISSUE_PARENT_CHILD_ISSUES_${peekIssue?.workspaceSlug}_${parentIssue.project_id}_${parentIssue.id}` : null, peekIssue && parentIssue && parentIssue.project_id ? () => fetchSubIssues(peekIssue?.workspaceSlug, parentIssue.project_id!, parentIssue.id) : null ); const subIssueIds = (parentIssue && subIssuesByIssueId(parentIssue.id)) || undefined; return (
{isLoading ? (
Loading
) : subIssueIds && subIssueIds.length > 0 ? ( subIssueIds.map( (issueId) => currentIssue.id != issueId && ) ) : (
No sibling issues
)}
); };