import React, { useState } from "react"; // headless ui import { Combobox, Dialog, Transition } from "@headlessui/react"; // icons import { MagnifyingGlassIcon, RectangleStackIcon } from "@heroicons/react/24/outline"; // ui import { PrimaryButton, SecondaryButton } from "components/ui"; // types import { IIssue } from "types"; import { LayerDiagonalIcon } from "components/icons"; type Props = { isOpen: boolean; handleClose: () => void; value?: any; onChange: (...event: any[]) => void; issues: IIssue[]; title?: string; multiple?: boolean; customDisplay?: JSX.Element; }; export const ParentIssuesListModal: React.FC = ({ isOpen, handleClose: onClose, value, onChange, issues, title = "Issues", multiple = false, customDisplay, }) => { const [query, setQuery] = useState(""); const [values, setValues] = useState([]); const handleClose = () => { onClose(); setQuery(""); setValues([]); }; const filteredIssues: IIssue[] = query === "" ? issues ?? [] : issues?.filter((issue) => issue.name.toLowerCase().includes(query.toLowerCase())) ?? []; return ( <> setQuery("")} appear>
{multiple ? ( <> ({})} multiple>
{customDisplay &&
{customDisplay}
} {filteredIssues.length > 0 && (
  • {query === "" && (

    {title}

    )}
      {filteredIssues.map((issue) => ( `flex cursor-pointer select-none items-center gap-2 rounded-md px-3 py-2 ${ active ? "bg-gray-900 bg-opacity-5 text-gray-900" : "" }` } > {({ selected }) => ( <> {issue.project_detail?.identifier}-{issue.sequence_id} {" "} {issue.id} )} ))}
  • )}
    {query !== "" && filteredIssues.length === 0 && (
    )}
    Cancel onChange(values)}>Add issues
    ) : (
    {customDisplay &&
    {customDisplay}
    } {filteredIssues.length > 0 ? (
  • {query === "" && (

    {title}

    )}
      {filteredIssues.map((issue) => ( `flex cursor-pointer select-none items-center gap-2 rounded-md px-3 py-2 ${ active ? "bg-gray-900 bg-opacity-5 text-gray-900" : "" }` } onClick={() => handleClose()} > <> {issue.project_detail?.identifier}-{issue.sequence_id} {" "} {issue.name} ))}
  • ) : (

    No issues found. Create a new issue with{" "}
    C
    .

    )}
    )}
    ); };