import React from "react"; import Link from "next/link"; import { observer } from "mobx-react-lite"; import { Pencil, X } from "lucide-react"; // hooks import { useIssueDetail, useProject } from "hooks/store"; // components import { ParentIssuesListModal } from "components/issues"; // ui import { Tooltip } from "@plane/ui"; // helpers import { cn } from "helpers/common.helper"; // types import { TIssueOperations } from "./root"; type TIssueParentSelect = { className?: string; disabled?: boolean; issueId: string; issueOperations: TIssueOperations; projectId: string; workspaceSlug: string; }; export const IssueParentSelect: React.FC = observer((props) => { const { className = "", disabled = false, issueId, issueOperations, projectId, workspaceSlug } = props; // store hooks const { getProjectById } = useProject(); const { issue: { getIssueById }, } = useIssueDetail(); const { isParentIssueModalOpen, toggleParentIssueModal } = useIssueDetail(); // derived values const issue = getIssueById(issueId); const parentIssue = issue?.parent_id ? getIssueById(issue.parent_id) : undefined; const parentIssueProjectDetails = parentIssue && parentIssue.project_id ? getProjectById(parentIssue.project_id) : undefined; const handleParentIssue = async (_issueId: string | null = null) => { try { await issueOperations.update(workspaceSlug, projectId, issueId, { parent_id: _issueId }); await issueOperations.fetch(workspaceSlug, projectId, issueId); toggleParentIssueModal(false); } catch (error) { console.error("something went wrong while fetching the issue"); } }; if (!issue) return <>; return ( <> toggleParentIssueModal(false)} onChange={(issue: any) => handleParentIssue(issue?.id)} /> ); });