import React from "react"; // react hook form import { Controller } from "react-hook-form"; // headless ui import { Listbox, Transition } from "@headlessui/react"; // hooks import useUser from "lib/hooks/useUser"; // icons import { CheckIcon } from "@heroicons/react/20/solid"; // types import type { IIssue } from "types"; import type { Control } from "react-hook-form"; import { UserIcon } from "@heroicons/react/24/outline"; type Props = { control: Control; }; const SelectParent: React.FC = ({ control }) => { const { issues: projectIssues } = useUser(); const getSelectedIssueKey = (issueId: string | undefined) => { const identifier = projectIssues?.results?.find((i) => i.id.toString() === issueId?.toString()) ?.project_detail.identifier; const sequenceId = projectIssues?.results?.find( (i) => i.id.toString() === issueId?.toString() )?.sequence_id; if (issueId) return `${identifier}-${sequenceId}`; else return "Parent issue"; }; return ( ( {({ open }) => ( <>
{getSelectedIssueKey(value?.toString())}
{projectIssues?.results?.map((issue) => ( `relative cursor-pointer select-none p-2 rounded-md ${ active ? "bg-theme text-white" : "text-gray-900" }` } > {({ active, selected }) => ( <> {issue.project_detail.identifier}-{issue.sequence_id} {" "} {issue.name} )} ))}
)}
)} /> ); }; export default SelectParent;