import React, { useState } from "react"; import { useRouter } from "next/router"; // react-hook-form import { UseFormWatch } from "react-hook-form"; // hooks import useToast from "hooks/use-toast"; // components import { ExistingIssuesListModal } from "components/core"; // icons import { XMarkIcon } from "@heroicons/react/24/outline"; import { BlockerIcon } from "components/icons"; // types import { BlockeIssueDetail, IIssue, ISearchIssueResponse, UserAuth } from "types"; type Props = { issueId?: string; submitChanges: (formData: Partial) => void; watch: UseFormWatch; disabled?: boolean; }; export const SidebarBlockerSelect: React.FC = ({ issueId, submitChanges, watch, disabled = false, }) => { const [isBlockerModalOpen, setIsBlockerModalOpen] = useState(false); const { setToastAlert } = useToast(); const router = useRouter(); const { workspaceSlug } = router.query; const handleClose = () => { setIsBlockerModalOpen(false); }; const onSubmit = async (data: ISearchIssueResponse[]) => { if (data.length === 0) { setToastAlert({ type: "error", title: "Error!", message: "Please select at least one issue.", }); return; } const selectedIssues: { blocker_issue_detail: BlockeIssueDetail }[] = data.map((i) => ({ blocker_issue_detail: { id: i.id, name: i.name, sequence_id: i.sequence_id, project_detail: { id: i.project_id, identifier: i.project__identifier, name: i.project__name, }, }, })); const newBlockers = [...watch("blocker_issues"), ...selectedIssues]; submitChanges({ blocker_issues: newBlockers, blockers_list: newBlockers.map((i) => i.blocker_issue_detail?.id ?? ""), }); handleClose(); }; return ( <> setIsBlockerModalOpen(false)} searchParams={{ blocker_blocked_by: true, issue_id: issueId }} handleOnSubmit={onSubmit} workspaceLevelToggle />

Blocking

{watch("blocker_issues") && watch("blocker_issues").length > 0 ? watch("blocker_issues").map((issue) => (
{`${issue.blocker_issue_detail?.project_detail.identifier}-${issue.blocker_issue_detail?.sequence_id}`}
)) : null}
); };