import React, { useState } from "react"; import { useRouter } from "next/router"; import useSWR from "swr"; import { Control, Controller, UseFormWatch } from "react-hook-form"; // fetch keys import { UserIcon } from "@heroicons/react/24/outline"; // services import issuesServices from "services/issues.service"; // components import { ParentIssuesListModal } from "components/issues"; // icons // types import { IIssue, UserAuth } from "types"; // fetch-keys import { PROJECT_ISSUES_LIST } from "constants/fetch-keys"; type Props = { control: Control; submitChanges: (formData: Partial) => void; customDisplay: JSX.Element; watch: UseFormWatch; userAuth: UserAuth; disabled?: boolean; }; export const SidebarParentSelect: React.FC = ({ control, submitChanges, customDisplay, watch, userAuth, disabled = false, }) => { const [isParentModalOpen, setIsParentModalOpen] = useState(false); const router = useRouter(); const { workspaceSlug, projectId, issueId } = router.query; const { data: issues } = useSWR( workspaceSlug && projectId ? PROJECT_ISSUES_LIST(workspaceSlug as string, projectId as string) : null, workspaceSlug && projectId ? () => issuesServices.getIssues(workspaceSlug as string, projectId as string) : null ); const isNotAllowed = userAuth.isGuest || userAuth.isViewer || disabled; return (

Parent

( setIsParentModalOpen(false)} onChange={(val) => { submitChanges({ parent: val }); onChange(val); }} issueId={issueId as string} value={value} customDisplay={customDisplay} /> )} />
); };