import React, { useState } from "react"; import { Combobox, Dialog, Transition } from "@headlessui/react"; // ui import { Button } from "ui"; // icons import { MagnifyingGlassIcon, RectangleStackIcon } from "@heroicons/react/24/outline"; // constants import { classNames } from "constants/common"; // types import { IIssue } from "types"; import { LayerDiagonalIcon } from "ui/icons"; type Props = { isOpen: boolean; handleClose: () => void; value?: any; onChange: (...event: any[]) => void; issues: IIssue[]; title?: string; multiple?: boolean; customDisplay?: JSX.Element; }; const IssuesListModal: 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}
{filteredIssues.length > 0 && (
  • {query === "" && (

    {title}

    )}
      {filteredIssues.map((issue) => ( classNames( "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 && (
    )}
    ) : (
    {customDisplay}
    {filteredIssues.length > 0 ? (
  • {query === "" && (

    {title}

    )}
      {filteredIssues.map((issue) => ( classNames( "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{" "}
                                  Ctrl/Command + I
                                
    .

    )}
    {query !== "" && filteredIssues.length === 0 && (
    )}
    )}
    ); }; export default IssuesListModal;